Skip to content

Commit

Permalink
Document standard tokens and provide examples (#3104)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonweiting committed Oct 21, 2021
1 parent 31b4c1b commit 3755120
Show file tree
Hide file tree
Showing 3 changed files with 443 additions and 5 deletions.
4 changes: 2 additions & 2 deletions extending.html
Expand Up @@ -60,8 +60,8 @@ <h1>Language definitions</h1>

<dt>alias</dt>
<dd>This option can be used to define one or more aliases for the matched token. The result will be, that
the styles of the token and its aliases are combined. This can be useful, to combine the styling of a well known
token, which is already supported by most of the themes, with a semantically correct token name. The option
the styles of the token and its aliases are combined. This can be useful, to combine the styling of a <a href="/tokens.html">standard
token</a>, which is already supported by most of the themes, with a semantically correct token name. The option
can be set to a string literal or an array of string literals. In the following example the token
name <code>latex-equation</code> is not supported by any theme, but it will be highlighted the same as a string.
<pre><code class="language-javascript">{
Expand Down
7 changes: 4 additions & 3 deletions faq.html
Expand Up @@ -21,7 +21,7 @@
<script>var _gaq = [['_setAccount', 'UA-33746269-1'], ['_trackPageview']];</script>
<script src="https://www.google-analytics.com/ga.js" async></script>
</head>
<body>
<body class="language-none">

<header>
<div class="intro" data-src="assets/templates/header-main.html" data-type="text/html"></div>
Expand Down Expand Up @@ -95,14 +95,15 @@ <h1>How do I know which tokens I can style for every language?</h1>

<p>Language: <select id="language-select"></select></p>
<pre class="language-none" style="height: 30em"><code id="print-tokens-output"></code></pre>

<p>Additionally, you can find a list of standard tokens on <a href="/tokens.html">this page</a>.</p>
</section>

<section>
<h1>How can I use different highlighting for tokens with the same name in different languages?</h1>
<p>Just use a descendant selector, that includes the language class. The default <code>prism.css</code> does this, to have different colors for
JavaScript strings (which are very common) and CSS strings (which are relatively rare). Here’s that code, simplified to illustrate the technique:
<pre><code class="language-css">
.token.string {
<pre><code class="language-css">.token.string {
color: #690;
}

Expand Down

0 comments on commit 3755120

Please sign in to comment.