Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting to code tags #2457

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Commits on Nov 17, 2023

  1. Add highlight.js dependency

    highlight.js will be used to do the highlighting in the web interface
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    aa8e66a View commit details
    Browse the repository at this point in the history
  2. Add SCSS for highlighting

    Imports necessary styles from highlight.js
    
    Github style has been chosen as a default, because it is what most people will be familiar with.
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    5d54afc View commit details
    Browse the repository at this point in the history
  3. Allow data-codelang attribute on code tags

    Allows users to set the language on code tags, which was previously discarded.
    
    Also allows this attribute on incoming toots.
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    f275873 View commit details
    Browse the repository at this point in the history
  4. Remove invalid data-codelang in backend

    Adds a new yml file containing all valid code languages which are supported by highlight.js
    
    This file has been created by a script as the list of supported languages is unreliable.
    
    This is not ideal, but highlight.js made it clear they won't add new languages natively. Instead additional language support is provided by third-party packages.
    If such a third-party package is installed, this file needs to be updated to support the new aliases.
    
    When an unsupported language is given, the `data-codelang` attribute is removed using a new transformer.
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    a22c3c3 View commit details
    Browse the repository at this point in the history
  5. Add Syntax highlighting to web UI

    Adds a new function to add syntax highlighting on `contentHtml`
    
    Also supports translated content.
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    57a7a17 View commit details
    Browse the repository at this point in the history
  6. Update specs

    Add tests to make sure valid `code-lang` attributes are kept and invalid ones removed.
    
    Signed-off-by: Plastikmensch <[email protected]>
    Plastikmensch committed Nov 17, 2023
    Configuration menu
    Copy the full SHA
    5416d99 View commit details
    Browse the repository at this point in the history