-
-
Notifications
You must be signed in to change notification settings - Fork 389
pre and code elements
ReSpec provides code highlighting for blocks of code marked up with the <pre>
or <code>
elements. ReSpec will try to guess the code language, or it can be added as a class (to disable syntax highlighting use the "nohighlight" class):
<pre> <!-- or <pre class="html"> -->
<script>
function magic() {
const noop = "this";
doThat(noop);
}
</script>
</pre>
Respec uses highlight.js for syntax highlighting and supports the following languages by default:
- ABNF
- CSS
- HTML
- HTTP
- JavaScript
- JSON
- XML
An advanced syntax highlighter for WebIDL is also available out of the box.
To highlight code in other languages you need to define a function that loads a highlighter.js package for the language you want, and to request the language be loaded as a respec preProcess
option:
async function loadSolidity() {
//this is the function you call in 'preProcess', to load the highlighter
const worker = await new Promise(resolve => {
require(["core/worker"], ({ worker }) => resolve(worker));
});
const action = "highlight-load-lang";
const langURL =
"https://rawgit.com/pospi/highlightjs-solidity/master/solidity.js";
const propName = "hljsDefineSolidity"; // This funtion is defined in the highlighter being loaded
const lang = "solidity"; // this is the class you use to identify the language
worker.postMessage({ action, langURL, propName, lang });
return new Promise(resolve => {
worker.addEventListener("message", function listener({ data }) {
const { action: responseAction, lang: responseLang } = data;
if (responseAction === action && responseLang === lang) {
worker.removeEventListener("message", listener);
resolve();
}
});
});
}
var respecConfig = {
// i.e. add this line to your existing configuration
preProcess: [loadSolidity],
// ... other configuration information
};
💖 Support ReSpec by becoming a sponsor via Open Collective. 💖
✨ View rendered version of this documentation at https://respec.org/docs/ ✨
- addSectionLinks
- authors
- caniuse
- edDraftURI
- editors
- favicon
- format (markdown)
- formerEditors
- github
- highlightVars
- isPreview
- license
- lint
- localBiblio
- logos
- maxTocLevel
- mdn
- modificationDate
- noTOC
- otherLinks
- pluralize
- postProcess
- preProcess
- previousDiffURI
- previousMaturity
- previousPublishDate
- prevRecShortname
- prevRecURI
-
processVersion(Deprecated) - publishDate
-
refNote(Deprecated) - shortName
- specStatus
- subjectPrefix
- subtitle
- testSuiteURI
- xref
- additionalCopyrightHolders
-
addPatentNote(Deprecated) - alternateFormats
- canonicalURI
- charterDisclosureURI
- copyrightStart
- crEnd
-
darkMode(deprecated, use dark mode) - doJsonLd
- errata
- group
- implementationReportURI
- lcEnd
- level
- noRecTrack
- prevED
- submissionCommentNumber
-
wg(Deprecated) -
wgId(Deprecated) -
wgPatentPolicy(Deprecated) -
wgPatentURI(Deprecated) - wgPublicList
-
wgURI(Deprecated)
a11y
check-punctuation
local-refs-exist
no-headingless-sections
no-http-props
no-unused-vars
no-unused-dfns
informative-dfn
privsec-section
wpt-tests-exist
Handled by ReSpec for you.
- data-abbr
-
data-cite(Not recommended) - data-dfn-for
- data-dfn-type
- data-format
- data-include-format
- data-include-replace
- data-include
- data-link-for
- data-link-type
- data-local-lt
- data-lt-no-plural
- data-lt-noDefault
- data-lt
- data-number
- data-oninclude
- data-sort
- data-tests
-
data-transform(Deprecated) - data-type
- dir
- lang