1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 17:40:29 +00:00
TiddlyWiki5/plugins/tiddlywiki/highlight
Talha Mansoor 04a4a0f92e Add support of language aliases in highlight.js plugin (#3898)
listLanguages() returns a list of supported languages. It does not
return language aliases.

highlight.js has extensive support of language aliases which can be 
viewed here

https://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases

But because of using listLanguages(), TW does not take advantage of 
alias.

getLanguage() method on the other hand supports aliases.

https://highlightjs.readthedocs.io/en/latest/api.html#getlanguage-name

To summarize, now user can use javascript, js or jsx for the code block. getLanguage() will return an object which means highlight.js supports
this language.
2019-04-15 18:45:45 +01:00
..
files Update highlight.js to latest release v9.15.6 (#3635) 2019-03-12 12:04:38 +00:00
highlightblock.js Add support of language aliases in highlight.js plugin (#3898) 2019-04-15 18:45:45 +01:00
howto.tid Add howto for changing highlight languages (#3674) 2019-01-14 09:32:58 +00:00
license.tid in resp to https://github.com/Jermolene/TiddlyWiki5/pull/328#issuecomment-32131402 2014-01-12 21:48:03 +00:00
plugin.info Add howto for changing highlight languages (#3674) 2019-01-14 09:32:58 +00:00
readme.tid Update highlight.js to latest release v9.15.6 (#3635) 2019-03-12 12:04:38 +00:00
styles.tid Revert to a pale default theme for highlight plugin 2015-04-17 16:05:54 +01:00
TypeMappings.multids Yet more tweaks to the highlight.js integration 2017-03-02 09:17:48 +00:00
usage.tid Revert "Add text/vnd.tiddlywiki to system tiddlers within plugins that should be wikified (c.f. #2883)" 2017-06-24 17:48:32 +01:00

title: $:/plugins/tiddlywiki/highlight/readme

This plugin provides syntax highlighting of code blocks using v9.15.6 of [[highlight.js|https://github.com/isagalaev/highlight.js]] from Ivan Sagalaev.

! Usage

When the plugin is installed it automatically applies highlighting to all codeblocks defined with triple backticks or with the CodeBlockWidget.

The language can optionally be specified after the opening triple braces:

<$codeblock code="""```css
 * { margin: 0; padding: 0; } /* micro reset */

html { font-size: 62.5%; }
body { font-size: 14px; font-size: 1.4rem; } /* =14px */
h1   { font-size: 24px; font-size: 2.4rem; } /* =24px */
```"""/>

If no language is specified highlight.js will attempt to automatically detect the language.

! Built-in Language Brushes

The plugin includes support for the following languages (referred to as "brushes" by highlight.js):

* apache
* arduino
* arm assembly
* asciidoc
* autohotkey
* awk
* bash
* cmake
* coffeescript
* cpp
* cs
* css
* diff
* dockerfile
* erlang
* fortran
* go
* gradle
* haskell
* html
* http
* ini
* intel x86 assembly
* java
* javascript
* json
* kotlin
* makefile
* markdown
* mathematica
* matlab
* nginx
* objectivec
* perl
* php
* powershell
* python
* R
* ruby
* rust
* sql
* typescript
* vim script
* xml
* yaml

You can also specify the language as a MIME content type (eg `text/html` or `text/css`). The mapping is accomplished via mapping tiddlers whose titles start with `$:/config/HighlightPlugin/TypeMappings/`.