Skip to content

Code Syntax Theming #36

Open
Open
@rafegoldberg

Description

@rafegoldberg

Technical documentation features a lot of code blocks. We already allow authors to customize the base background and text colors for code blocks. We should extend this support to the complete syntax highlighting theme.

CSS-Based Themes

Using syntax selectors & highlight variables to override the default theme:

.markdown-body pre .cm {
  &-node        {  color:  var(--md-syntax-string,     #9c3328)  }
  &-tag         {  color:  var(--md-syntax-string,     #9c3328)  }
  &-string      {  color:  var(--md-syntax-string,     #b35e14)  }
  &-number      {  color:  var(--md-syntax-number,     #75438a)  }
  &-property    {  color:  var(--md-syntax-property,   #1d75b3)  }
  &-keyword     {  color:  var(--md-syntax-keyword,    #1d75b3)  }
  &-qualifier   {  color:  var(--md-syntax-qualifier,  #047d65)  }
  &-variable    {  color:  var(--md-syntax-var,        #047d65)  }
  &-variable-2  {  color:  var(--md-syntax-var-alt,    #ffffff)  }
  &-comment     {  color:  var(--md-syntax-comment,    #75787b)  }
  &-atom        {  color:  var(--md-syntax-atom,       #75438a)  }
  &-operator    {  color:  var(--md-syntax-operator,   #ffffff)  }
  &-def         {  color:  var(--md-syntax-def,        #ffffff)  }
}
Issues
  • lots of manual Custom CSS config required (still, it's better than some of the crazy things I've seen done to get this working though!)
  • will revert to default theme in older browsers (without a polyfill at least!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions