Skip to content

Commit

Permalink
Compatibility with autolinker and other fixes
Browse files Browse the repository at this point in the history
+ changed `string` aliases to `char` to disable autolinking
+ removed hard-coded list of "known" types and fields
  • Loading branch information
SaswatPadhi committed Sep 13, 2019
1 parent 218606a commit ec59f86
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 101 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

<hr>

## [Unreleased]

No changes

<hr>

## [1.1.0] - 2019-09-13
### Fixed
- Compatibility with `autolinker` plugin -- disabled autolinking except within comments.
### Removed
- Removed hardcoded list of "known" types and field names -- all field names are treated the same way now.

<hr>

## [1.0.0] - 2019-03-17
### Added
- Added initial regexes for parsing BibTeX files in PrismJS framework.
Expand All @@ -14,4 +28,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


[Unreleased]: https://github.com/SaswatPadhi/prismjs-bibtex/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/SaswatPadhi/prismjs-bibtex/releases/tag/v1.0.0
[1.0.0]: https://github.com/SaswatPadhi/prismjs-bibtex/releases/tag/v1.0.0
[1.0.0]: https://github.com/SaswatPadhi/prismjs-bibtex/releases/tag/v1.1.0
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[PrismJS] is great! The minified core is less than 6&thinsp;KB, the API is gorgeous,
PrismJS-BibTeX
<a href="https://www.npmjs.com/package/prismjs-bibtex"><img align="right" alt="npm" src="https://img.shields.io/npm/v/prismjs-bibtex?logo=npm&style=for-the-badge"></a><img align="right" alt="npm bundle minified size" src="https://img.shields.io/bundlephobia/min/prismjs-bibtex?label=minified&logo=javascript&style=for-the-badge">
========

[PrismJS] is great! The minified core is less than ~5&thinsp;KB, the API is gorgeous,
and although it uses simple regex matching, it is surprisingly accurate in most cases.
However, although it officially supports 175 languages currently, there is no support for [BibTeX] &#x1f612; ...

So here is a BibTeX language extension for PrismJS! &#x1f601;
So here is a BibTeX language extension for PrismJS!
<br>
Thanks to the fantastic extension support in PrismJS,
it took me less than an hour and only about 60 lines to write the initial version.
The minified JS file is less than 1.5&thinsp;KB and all you need to do to highlight those BibTeX snippets,
is just load it after `prism.js`.
The minified JS file is less than 1&thinsp;KB and all you need to do to highlight those BibTeX snippets, is just load it after `prism.js`.



Expand All @@ -31,18 +34,16 @@ Using this extension is super simple --- just import `prism-bibtex.min.js` in th
For example:

```html
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css"/>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"></script>
<script defer src="https://saswatpadhi.github.io/prismjs-bibtex/prism-bibtex.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js"></script>
<script src="https://saswatpadhi.github.io/prismjs-bibtex/prism-bibtex.min.js"></script>
```

The `defer` attribute delays the script execution (but not download) until the HTML page has been parsed completely.



## &raquo; Usage with Node

Install the package using `npm install prismjs-biblatex`.
Install the package using `npm install prismjs-bibtex`.



Expand Down
5 changes: 1 addition & 4 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
source 'https://rubygems.org'

gem 'jekyll', '~> 3.4'
gem "github-pages", group: :jekyll_plugins
gem 'wdm', '~> 0.1', :install_if => Gem.win_platform?
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
gem 'github-pages', group: :jekyll_plugins
54 changes: 25 additions & 29 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.10)
activesupport (4.2.11.1)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
Expand All @@ -16,7 +16,7 @@ GEM
commonmarker (0.17.13)
ruby-enum (~> 0.5)
concurrent-ruby (1.1.5)
dnsruby (1.61.2)
dnsruby (1.61.3)
addressable (~> 2.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
Expand All @@ -27,13 +27,13 @@ GEM
execjs (2.7.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.10.0)
ffi (1.11.1)
forwardable-extended (2.6.0)
gemoji (3.0.0)
github-pages (197)
activesupport (= 4.2.10)
gemoji (3.0.1)
github-pages (198)
activesupport (= 4.2.11.1)
github-pages-health-check (= 1.16.1)
jekyll (= 3.7.4)
jekyll (= 3.8.5)
jekyll-avatar (= 0.6.0)
jekyll-coffeescript (= 1.1.1)
jekyll-commonmark-ghpages (= 0.1.5)
Expand Down Expand Up @@ -81,13 +81,13 @@ GEM
octokit (~> 4.0)
public_suffix (~> 3.0)
typhoeus (~> 1.3)
html-pipeline (2.10.0)
html-pipeline (2.12.0)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jekyll (3.7.4)
jekyll (3.8.5)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand All @@ -105,9 +105,9 @@ GEM
jekyll-coffeescript (1.1.1)
coffee-script (~> 2.2)
coffee-script-source (~> 1.11.1)
jekyll-commonmark (1.2.0)
jekyll-commonmark (1.3.1)
commonmarker (~> 0.14)
jekyll (>= 3.0, < 4.0)
jekyll (>= 3.7, < 5.0)
jekyll-commonmark-ghpages (0.1.5)
commonmarker (~> 0.17.6)
jekyll-commonmark (~> 1)
Expand Down Expand Up @@ -185,7 +185,7 @@ GEM
jekyll-seo-tag (~> 2.0)
jekyll-titles-from-headings (0.5.1)
jekyll (~> 3.3)
jekyll-watch (2.1.2)
jekyll-watch (2.2.1)
listen (~> 3.0)
jemoji (0.10.2)
gemoji (~> 3.0)
Expand All @@ -204,49 +204,45 @@ GEM
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.11.3)
multipart-post (2.0.0)
nokogiri (1.10.1)
multipart-post (2.1.1)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
octokit (4.13.0)
octokit (4.14.0)
sawyer (~> 0.8.0, >= 0.5.3)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (3.0.3)
public_suffix (3.1.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rouge (2.2.1)
ruby-enum (0.7.2)
i18n
ruby_dep (1.5.0)
rubyzip (1.2.2)
rubyzip (1.2.4)
safe_yaml (1.0.5)
sass (3.7.3)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sawyer (0.8.1)
addressable (>= 2.3.5, < 2.6)
faraday (~> 0.8, < 1.0)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
typhoeus (1.3.1)
ethon (>= 0.9.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.5.0)
wdm (0.1.1)
unicode-display_width (1.6.0)

PLATFORMS
ruby

DEPENDENCIES
github-pages
jekyll (~> 3.4)
tzinfo-data
wdm (~> 0.1)

BUNDLED WITH
1.16.5
2.0.2
17 changes: 11 additions & 6 deletions docs/acm-turing-awards.md
Original file line number Diff line number Diff line change
Expand Up @@ -3285,10 +3285,15 @@ Source: <ftp://ftp.math.utah.edu/pub/tex/bib/acm-turing-awards.bib>
}{% endraw %}
```

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css"
integrity="sha256-uv4VzRy3z4cpObdkSN+OCocMJpELBaOtNcmCa6Wgyws=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"
integrity="sha256-jc6y1s/Y+F+78EgCT/lI2lyU7ys+PFYrRSJ6q8/R8+o=" crossorigin="anonymous"></script>
<script src="prism-bibtex.min.js" integrity="sha256-fGDTNGNhZgaIwZoMiPCbMC2ufG10eUT8UJRYEjgzxck=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css"
integrity="sha256-3cT9py3J5XXzJkB9HvDuXrIgL+db6zf7BF2F+TBYdoo=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js"
integrity="sha256-HWJnMZHGx7U1jmNfxe4yaQedmpo/mtxWSIXvcJkLIf4=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autolinker/prism-autolinker.min.js"
integrity="sha256-Qfxn8KLcPNmSqfiY/b9HKceQvP0g9EXwiDHDCcgfC2k=" crossorigin="anonymous">
</script>
<script src="prism-bibtex.min.js" crossorigin="anonymous"
integrity="sha256-LdLe3QDoMjP5ed5hKliTe+/DmOChPYalAAjUNS+j2Lg=">
</script>
17 changes: 11 additions & 6 deletions docs/biblatex-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,15 @@ Source: <http://mirror.ctan.org/macros/latex/contrib/biblatex/bibtex/bib/biblate
}{% endraw %}
```

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css"
integrity="sha256-uv4VzRy3z4cpObdkSN+OCocMJpELBaOtNcmCa6Wgyws=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"
integrity="sha256-jc6y1s/Y+F+78EgCT/lI2lyU7ys+PFYrRSJ6q8/R8+o=" crossorigin="anonymous"></script>
<script src="prism-bibtex.min.js" integrity="sha256-fGDTNGNhZgaIwZoMiPCbMC2ufG10eUT8UJRYEjgzxck=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css"
integrity="sha256-3cT9py3J5XXzJkB9HvDuXrIgL+db6zf7BF2F+TBYdoo=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js"
integrity="sha256-HWJnMZHGx7U1jmNfxe4yaQedmpo/mtxWSIXvcJkLIf4=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autolinker/prism-autolinker.min.js"
integrity="sha256-Qfxn8KLcPNmSqfiY/b9HKceQvP0g9EXwiDHDCcgfC2k=" crossorigin="anonymous">
</script>
<script src="prism-bibtex.min.js" crossorigin="anonymous"
integrity="sha256-LdLe3QDoMjP5ed5hKliTe+/DmOChPYalAAjUNS+j2Lg=">
</script>
49 changes: 26 additions & 23 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
[PrismJS] is great! The minified core is less than 6&thinsp;KB, the API is gorgeous,
[PrismJS] is great! The minified core is less than ~5&thinsp;KB, the API is gorgeous,
and although it uses simple regex matching, it is surprisingly accurate in most cases.
However, although it officially supports 175 languages currently, there is no support for [BibTeX] &#x1f612; ...

So here is a BibTeX language extension for PrismJS! &#x1f601;
So here is a BibTeX language extension for PrismJS!
<br>
Thanks to the fantastic extension support in PrismJS,
it took me less than an hour and only about 60 lines to write the initial version.
The minified JS file is less than 1.5&thinsp;KB and all you need to do to highlight those BibTeX snippets,
is just load it after `prism.js`.
The minified JS file is less than 1&thinsp;KB and all you need to do to highlight those BibTeX snippets, is just load it after `prism.js`.



Expand All @@ -17,25 +16,23 @@ Using this extension is super simple --- just import the JS file after all the r
In the `head` of you HTML document, you can add the following:

<pre class='language-html' data-line='13-16'><code>&lt;!-- Import the desired stylesheet for Prism: (`solarizedlight` theme shown below). --&gt;
&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css&quot;
integrity=&quot;sha256-uv4VzRy3z4cpObdkSN+OCocMJpELBaOtNcmCa6Wgyws=&quot;
&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css&quot;
integrity=&quot;sha256-3cT9py3J5XXzJkB9HvDuXrIgL+db6zf7BF2F+TBYdoo=&quot;
rel=&quot;stylesheet&quot; crossorigin=&quot;anonymous&quot;/&gt;

&lt;!-- Import the main driver file for Prism. --&gt;
&lt;script defer src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js&quot;
integrity=&quot;sha256-jc6y1s/Y+F+78EgCT/lI2lyU7ys+PFYrRSJ6q8/R8+o=&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js&quot;
integrity=&quot;sha256-HWJnMZHGx7U1jmNfxe4yaQedmpo/mtxWSIXvcJkLIf4=&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;/script&gt;

&lt;!-- Import other components and plugins as desired. --&gt;

&lt;!-- Import the `prism-bibtex.js` extension. --&gt;
&lt;script defer src=&quot;https://saswatpadhi.github.io/prismjs-bibtex/prism-bibtex.min.js&quot;
integrity=&quot;sha256-fGDTNGNhZgaIwZoMiPCbMC2ufG10eUT8UJRYEjgzxck=&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;script src=&quot;https://saswatpadhi.github.io/prismjs-bibtex/prism-bibtex.min.js&quot;
integrity=&quot;sha256-LdLe3QDoMjP5ed5hKliTe+/DmOChPYalAAjUNS+j2Lg=&quot; crossorigin=&quot;anonymous&quot;&gt;
&lt;/script&gt;
</code></pre>

The `defer` attribute delays the script execution (but not download) until the HTML page has been parsed completely.



## &raquo; Some Basic Examples
Expand Down Expand Up @@ -203,20 +200,26 @@ Example from <https://tex.stackexchange.com/questions/73293/how-to-use-string-va
}{% endraw %}
```

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css"
integrity="sha256-uv4VzRy3z4cpObdkSN+OCocMJpELBaOtNcmCa6Wgyws=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/plugins/line-highlight/prism-line-highlight.min.css"
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css"
integrity="sha256-3cT9py3J5XXzJkB9HvDuXrIgL+db6zf7BF2F+TBYdoo=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/line-highlight/prism-line-highlight.min.css"
integrity="sha256-FFGTaA49ZxFi2oUiWjxtTBqoda+t1Uw8GffYkdt9aco=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"
integrity="sha256-jc6y1s/Y+F+78EgCT/lI2lyU7ys+PFYrRSJ6q8/R8+o=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/components/prism-markup.min.js"
integrity="sha256-QciVGr0G0qBC7iVqTH0zo6B2h4sFTL5iyxA3vO0Mu2M=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/plugins/line-highlight/prism-line-highlight.min.js"
integrity="sha256-DEl9ZQE+lseY13oqm2+mlUr+sVI18LG813P+kzzIm8o=" crossorigin="anonymous"></script>
<script src="prism-bibtex.min.js" integrity="sha256-fGDTNGNhZgaIwZoMiPCbMC2ufG10eUT8UJRYEjgzxck=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js"
integrity="sha256-HWJnMZHGx7U1jmNfxe4yaQedmpo/mtxWSIXvcJkLIf4=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/prism-markup.min.js"
integrity="sha256-8nT1E50WC5TDeb3+USsFEXN5ZGgLdmwZ6RS5KT71Wjs=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autolinker/prism-autolinker.min.js"
integrity="sha256-Qfxn8KLcPNmSqfiY/b9HKceQvP0g9EXwiDHDCcgfC2k=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/line-highlight/prism-line-highlight.min.js"
integrity="sha256-i1I0MEGBEKKEtBLlagkEPdef5OGDQEUdcjCPYo47a3Y=" crossorigin="anonymous">
</script>
<script src="prism-bibtex.min.js" crossorigin="anonymous"
integrity="sha256-LdLe3QDoMjP5ed5hKliTe+/DmOChPYalAAjUNS+j2Lg=">
</script>


## &raquo; Large Real-Life Bibliographies

Expand Down
2 changes: 1 addition & 1 deletion docs/prism-bibtex.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions docs/stoc_2010-2019.md
Original file line number Diff line number Diff line change
Expand Up @@ -10300,10 +10300,15 @@ Source: <ftp://ftp.math.utah.edu/pub/tex/bib/stoc2010.bib>
}{% endraw %}
```

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/themes/prism-solarizedlight.min.css"
integrity="sha256-uv4VzRy3z4cpObdkSN+OCocMJpELBaOtNcmCa6Wgyws=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.15.0/prism.min.js"
integrity="sha256-jc6y1s/Y+F+78EgCT/lI2lyU7ys+PFYrRSJ6q8/R8+o=" crossorigin="anonymous"></script>
<script src="prism-bibtex.min.js" integrity="sha256-fGDTNGNhZgaIwZoMiPCbMC2ufG10eUT8UJRYEjgzxck=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/themes/prism-solarizedlight.min.css"
integrity="sha256-3cT9py3J5XXzJkB9HvDuXrIgL+db6zf7BF2F+TBYdoo=" crossorigin="anonymous" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/prism.min.js"
integrity="sha256-HWJnMZHGx7U1jmNfxe4yaQedmpo/mtxWSIXvcJkLIf4=" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/plugins/autolinker/prism-autolinker.min.js"
integrity="sha256-Qfxn8KLcPNmSqfiY/b9HKceQvP0g9EXwiDHDCcgfC2k=" crossorigin="anonymous">
</script>
<script src="prism-bibtex.min.js" crossorigin="anonymous"
integrity="sha256-LdLe3QDoMjP5ed5hKliTe+/DmOChPYalAAjUNS+j2Lg=">
</script>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prismjs-bibtex",
"version": "1.0.0",
"version": "1.1.0",
"description": "A language definition for BibTeX in the PrismJS syntax-highlighting framework.",
"main": "prism-bibtex.js",
"dependencies": {
Expand Down
Loading

0 comments on commit ec59f86

Please sign in to comment.