Syntax.js

💻 A lightweight, and easy-to-use, JavaScript library for code syntax highlighting!

MIT License

Downloads
228
Stars
198

Language Shift:

  • The entire project has been rewritten in TypeScript, allowing all components to be exported, which allows better support for libraries such as React, Angular, etc.
  • Added CDN links for the minimized version of the files.
  • The TypeScript code is compiled to ES2016 instead of ES5 (older browsers, such as IE, are no longer supported).

Building:

  • You can now run separate builds to produce CJS, ESM, and Minimized project versions.
  • All files not required for the NPM packages have now been excluded.

Binding Options:

  • BREAKING: All the event custom triggers are now under a new section called "events".

Configuration Options:

  • BREAKING: All the text options are now under a new section called "text".
  • BREAKING: All the event custom triggers are now under a new section called "events".
  • The configuration setting "text.buttonsOpenerText" now defaults to the "←" character.
  • The configuration setting "text.buttonsCloserText" now defaults to the "→" character.

Tabs Binding Options:

  • BREAKING: All the event custom triggers are now under a new section called "events".

Testing:

  • Removed the "src" and "dist" folders under "test". Only the dist versions remain, removing duplication.
  • Added "BUILD_INSTRUCTIONS.md" to help first-time users set up their dev environments.

Fixes:

  • Fixed the custom triggers "onKeywordClicked", "onValueClicked", and "onAttributeClicked" not firing in Tabs mode.
  • Fixed the custom triggers "onKeywordClicked", "onValueClicked", and "onAttributeClicked" not firing when colors are disabled.
Syntax.js - Syntax.js v2.6.0 - Translations support! Export to third-party library support!

Published by williamtroup 4 months ago

New Features:

  • Added export support for the global "$syntax" object, which can now be imported as "syntax.js".
  • Added a new folder to "dist" called translations, and added translation files for the following languages:
    1. af Afrikaans
    2. ar Arabic
    3. hy Armenian
    4. be Belarusian
    5. bn Bengali
    6. bg Bulgarian
    7. ca Catalan
    8. zh Chinese (simplified)
    9. da Danish
    10. nl Dutch
    11. en English (default)
    12. eo Esperanto
    13. et Estonian
    14. fa Farsi
    15. fi Finnish
    16. fr French
    17. fy Frisian
    18. gl Galician
    19. ka Georgian
    20. de German
    21. el Greek
    22. he Hebrew
    23. hi Hindi
    24. hu Hungarian
    25. is Icelandic
    26. id Indonesian
    27. ga Irish
    28. it Italian
    29. ja Japanese
    30. ko Korean
    31. lv Latvian
    32. lt Lithuanian
    33. lb Luxembourgish
    34. ms Malay
    35. ne Nepali
    36. no Norwegian
    37. pl Polish
    38. pt Portuguese
    39. ro Romanian
    40. si Sinhalese
    41. sk Slovak
    42. sl Slovenian
    43. es Spanish
    44. sv Swedish
    45. tl Tagalog
    46. ta Tamil
    47. zh-tw Taiwanese
    48. te Telugu
    49. th Thai
    50. tr Turkish
    51. uk Ukrainian

Configuration Options:

  • The binding options "copyButtonText" and "printButtonText" are now part of the main configuration.
Syntax.js - Syntax.js v2.5.0 - Use Strict! New configuration options! Fixes!

Published by williamtroup 7 months ago

Configuration Options:

  • Added a new configuration option called "objectErrorText", which states the error text that should be shown when an object error is detected (defaults to "Errors in object: {{error_1}}, {{error_2}}").
  • Added a new configuration option called "attributeNotSetErrorText", which states the error text that should be shown when a binding attribute isn't set (defaults to "The attribute '{{attribute_name}}' has not been set correctly.").
  • Added a new configuration option called "languageNotSupportedErrorText", which states the error text that should be shown when a language detected is not supported (defaults to "Language '{{language}}' is not supported.").
  • Added a new configuration option called "noCodeAvailableToRenderErrorText", which states the error text that should be shown when there is no code to render (defaults to "No code is available to render.").

Improvements:

  • Added "use strict" support internally and updated all public functions to use the new scope.
  • Minor improvements to the README and README_NUGET files.
  • All default parameters are now read more accurately and apply the correct defaults.

Fixes:

  • Fixed a minor formatting issue in the "package.json" file.
  • Fixed a bad error message when no code is available to render.
Syntax.js - Syntax v2.4.3 - Documentation updates!

Published by williamtroup 8 months ago

  • Documentation has been removed, as it is available on the main website.
Syntax.js - Syntax.js - v2.4.2 - Hover effect / general improvements!

Published by williamtroup 9 months ago

  • All hover transition effects now work for hovering, and not hovering, which results in a smoother display.
  • Minor updates to the documentation.
  • Added a new ":root" variable called "--syntax-js-default-font" (specifies the default font).
  • Fixed the "journey.js.nuspec" file including the ".github" folder when NuGet PACK is called.
  • Added install instructions into the main README files.
  • Added Math injection directly into the main instance.
  • Added JSON injection directly into the main instance.
Syntax.js - Syntax v2.4.1 - Documentation improvements!

Published by williamtroup 9 months ago

  • Added correct year to all files, and added missing year to all minimized/dist files.
  • Fixed HTML files using the wrong formatting for meta, and imports being missing.
  • Improved the documentation in the main README files.
Syntax.js - Syntax.js v2.4.0 - CSS improvements and new website!

Published by williamtroup 10 months ago

  • BREAKING: All ":root" variables now start with "--syntax-js-", which will prevent collisions with other libraries.
  • Updated project homepage URL.
Syntax.js - Syntax.js v2.3.1 - Style improvements and new Custom Triggers!

Published by williamtroup 10 months ago

  • Comments are now italic by default.
  • Added a new binding custom trigger called "onButtonsClosed", which states an event that should be triggered when the buttons are closed.
  • Added a new binding custom trigger called "onButtonsOpened", which states an event that should be triggered when the buttons are closed.
  • Minor documentation improvements.
Syntax.js - Syntax.js v2.3.0 - RegEx support! Improved Custom Triggers! Fixes!

Published by williamtroup 10 months ago

Languages:

  • Added a new JSON property called "wordRegEx", which states the Regular Expression that is used for looking up keywords, values, attributes, and tags (optional, use %word% to state the lookup).

Binding Options - Custom Triggers:

  • Added a new binding custom trigger called "onBeforeRenderComplete", which states an event that should be triggered before an element is rendered.

Configuration Options:

  • Added new configuration option "allowHtmlInTextDisplay" (defaults to true), which states if HTML can be used in the text displays (buttons, tabs, descriptions, etc).

General Improvements:

  • Double-clicking in the description container (when tabs are used) will now select all the code (if the setting is turned on).

CSS:

  • Renamed some of the ":root" variables so they are easier to read.
  • Improved browser support for the no-text selection CSS.

Fixes:

  • Fixed a fault that prevented non-highlighted keywords and values from being rendered correctly when "highlightKeywords" and "highlightValues" were set to false.
  • Fixed a fault that caused the custom scroll bars to now show the right border color.
Syntax.js - Syntax.js v2.2.0 - CSS support! Tab Descriptions! New custom triggers!

Published by williamtroup 10 months ago

New Features:

  • Added "description" support for the binding attribute "data-syntax-tab-contents" options. When set, this will show a description panel next to the code.

Languages:

  • Added support for the CSS styling language (importable file).
  • The JSON property "comment" is now optional.
  • The RegEx used for searching for keywords, values, attributes, and tags, is now much more accurate.

Configuration Options - Custom Triggers:

  • Added a new configuration custom trigger called "onBeforeRender", which states an event that should be triggered before any DOM elements are rendered (when found).
  • Added a new configuration custom trigger called "onAfterRender", which states an event that should be triggered after any DOM elements are rendered (when found).

CSS:

  • Added new ":root" variable "--container-background-color-description", which states the background color to use for the description panel (for tabs).
  • Added new ":root" variable "--container-border-color-description", which states the border color to use for the description panel (for tabs).

Documentation:

  • Some more of the documentation has been renamed and moved into category folders (the filenames were getting confusing).
Syntax.js - Syntax.js v2.1.1 - Minor fix!

Published by williamtroup 10 months ago

  • Added an extra check when processing the attribute "data-syntax-tab-contents" options.
Syntax.js - Syntax.js v2.1.0 - Tab binding configuration!

Published by williamtroup 10 months ago

New Features:

  • Added full binding support for "data-syntax-tab-contents", which allows some configuration to be set per tab.

Binding Options Tab Contents:

  • Added a new binding option called "title", which states the title to use for a Tab (defaults to null, which forces the language name to be used).

Binding Options Tab Contents - Custom Triggers:

  • Added a new binding custom trigger called "onOpen", which states an event that should be triggered when a tab is opened (passes to the language to the event).

CSS:

  • Renamed the CSS class "label" to "language-label" (much clearer).

Documentation:

  • Minor documentation improvements.
  • Added new binding documentation file "binding/tabs/TAB_CONTENTS.md".
  • Added new binding documentation file "binding/tabs/CUSTOM_TRIGGERS.md".
  • Some of the documentation has been renamed and moved into category folders (the filenames were getting confusing).

General Improvements:

  • Code cleanups and refactoring to make things clearer.
Syntax.js - Syntax.js v2.0.1 - Documentation improvements!

Published by williamtroup 10 months ago

  • Minor documentation improvements.
Syntax.js - Syntax.js v2.0.0 - Tabs! New languages! CSS improvements!

Published by williamtroup 10 months ago

New Features:

  • Added tabbing support! This feature allows you to render languages under one tabbed container (which is great for showing code examples).

Languages:

  • Added support for the Powershell programming language (importable file).
  • Added support for the Dart programming language (importable file).
  • Added support for the Delphi programming language (importable file).
  • Added support for the Lua programming language (importable file).

CSS:

  • All buttons (and tabs) are now rendered as buttons instead of divs (this includes minor CSS changes).
  • Added new ":root" variable "--button-hover-background-color", which states the background color to use for the buttons when hovered (including custom ones, unless overridden).
  • Added new ":root" variable "--button-hover-text-color", which states the text color to use for the buttons when hovered (including custom ones, unless overridden).

Documentation:

  • Added a new documentation file "BINDING_LANGUAGE.md", which states how the "data-syntax-language" binding attribute is used.
  • Examples are now shown on all documentation pages to make things easier when starting with Syntax.js.
Syntax.js - Syntax.js v1.9.0 - Markup attribute highlighting support!

Published by williamtroup 11 months ago

New Features:

  • Added "Attributes" support for languages, which allows attributes (for markup languages only) to be rendered using a different CSS class.

Binding Options:

  • Added a new binding option called "highlightAttributes", which states if attributes should be highlighted (defaults to true).

Binding Options - Custom Triggers:

  • Added a new binding custom trigger called "onAttributeClicked", which states an event that should be triggered when an attribute is clicked.
  • Added a new binding custom trigger called "onAttributeRender", which states an event that should be triggered when an attribute is rendered.

Documentation:

  • Fixed documentation errors in the "BINDING_OPTIONS_CUSTOM_TRIGGERS.md" file.
  • Added support for the PHP programming language (importable file).
  • Minor improvement to the dark-mode theme to make sure the language label stands out a little more.
  • Grammar and spelling corrections across the project.
  • More internal renaming to make things a bit clearer.
  • Unknown language types, and non-markup-based languages, are now encoded before the main render is done (so special characters show up correctly).
  • Moved the configuration option "buttonsVisible" to the binding options (so it can be set per DOM element).
  • Moved the configuration option "maximumButtons" to the binding options (so it can be set per DOM element).
  • Fixed a fault that caused the buttons to be hidden (and could not be shown) when the total buttons are smaller (or equal) to "maximumButtons" and "buttonsVisible" is false.
Syntax.js - Syntax.js v1.8.1 - Minor improvements!

Published by williamtroup 11 months ago

  • Minor error logging improvements (uses less code and can be re-used as needed).
  • Internal refactoring to make some of the code match up to the names of the sections.

Public Functions:

  • Added new public function "getCode()", which is used to return all of the code inside an element (without rendering colors).

Languages:

  • Added support for the Perl programming language (importable file).
  • Added support for the Bash scripting language (importable file).
  • Added support for the Kotlin programming language (importable file).\
  • Added support for the R programming language (importable file).
  • Added support for the Matlab programming language (importable file).
  • Added support for the Scala programming language (importable file).
  • Moved some of the keywords for the supported languages into "values".
  • Multi-line comments are now processed before single-line comments.

Binding Options:

  • Added a new binding option called "doubleClickToSelectAll", which states that double-clicking in one of the containers (numbers, code) will select all the code (defaults to true).
  • Added a new binding option called "languageLabelCasing", which states the casing to use for the language label (defaults to "uppercase").

CSS:

  • Added new ":root" variable "--button-background-color", which will allow you to set the background color of the buttons.
  • Added new ":root" variable "--button-text-color", which will allow you to set the text color of the buttons.
  • Massively improved the theme "dark-mode" (much cleaner and modern).
  • Shared colors now reference the original base ":root" variable.

General Improvements:

  • Double-clicking in the code container will now select all the code (if the new setting is turned on).
  • Removed a lot of duplicated code.
  • Lots of clean-ups across the HTML testing files.
Syntax.js - Syntax.js v1.7.3 - New CSS classes, settings, and extended event support!

Published by williamtroup 11 months ago

  • The custom buttons "onClick" event now accepts the code as a parameter (see documentation).
  • Fixed a fault that caused the wrong events to be assigned to the custom buttons when there is more than one.
  • Added a new binding option called "removeDuplicateBlankLines" (defaults to true), which will remove all duplicate blank lines.
  • Fixed some bad documentation.
  • Added a new CSS class "multi-line-comment", which is used for multi-line comments.
  • Added a new CSS class "multi-line-string", which is used for multi-line strings.
Syntax.js - Syntax.js v1.7.2 - Markup language comment support!

Published by williamtroup 11 months ago

  • Added "multiLineComment" support for Markup languages (HTML, for example).
  • Minor code cleanups to make things a bit more readable.