Syntax.js

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

MIT License

Downloads
228
Stars
198
Syntax.js - Syntax.js v1.7.1 - Documentation improvement and quick-action files!

Published by williamtroup 11 months ago

  • More documentation improvements.
  • Added shortcut files for quickly packing/publishing the project.
Syntax.js - Syntax.js v1.7.0 - Markup language support!

Published by williamtroup 11 months ago

New Features:

  • Markup language support!

Highlighting:

  • If there is no code available for highlighting, the element is skipped and left as is (an error log is thrown when safeMode is off).

Languages:

  • Added support for the HTML markup language (importable file).
  • Added a new JSON property called "isMarkUp", which states if the language is a markup language (processed slightly differently).

Documentation:

  • More documentation fixes and improvements.

Fixes:

  • Fixed a fault that caused comments and strings from other elements to be added to others.
Syntax.js - Syntax.js v1.6.2 - Documentation fixes!

Published by williamtroup 11 months ago

  • Internal code cleanup to make object parsing a little clearer.
  • More documentation fixes.
  • Minor CSS comment updates.
Syntax.js - Syntax.js v1.6.1 - Documentation updates!

Published by williamtroup 11 months ago

  • Fixed some of the documentation files that were pointing at the wrong files.
Syntax.js - Syntax.js v1.6.0 - Value rendering, button hiding, UI improvements, and fixes!

Published by williamtroup 11 months ago

New Features:

  • Added "Values" support for languages, which allows values (such as "true" and "false") to be rendered using a different CSS class.
  • Added opening/closing support for the buttons shown in the top right corner (along with configurable options).

Binding Options:

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

Binding Options - Custom Triggers:

  • Added a new binding custom trigger called "onValueClicked", which states an event that should be triggered when a value is clicked.
  • Added a new binding custom trigger called "onValueRender", which states an event that should be triggered when a value is rendered.

Themes:

  • All CSS colors are now root variables, allowing full themes to be generated without referring CSS class names.
  • Added a new folder under "dist" called "themes", which contains a new dark mode (works based on the browser configuration).

Configuration Options:

  • Added new configuration option "maximumButtons" (defaults to 2), which states the maximum number of buttons that can be shown before the opening/closing button is shown.
  • Added new configuration option "buttonsVisible" (defaults to true), which states if the buttons are open (visible).
  • Added new configuration option "buttonsOpenerText" (defaults to "<"), which states the text that should be used for the open buttons button.
  • Added new configuration option "buttonsCloserText" (defaults to ">"), which states the text that should be used for the close buttons button.

CSS:

  • Renamed the CSS class "number" to "numbers".
  • By default, the buttons are no longer bold.
  • By default, the language label is now bold and uses a grey font color.

Documentation:

  • Documentation renames and cleanups to make things clearer.

Fixes:

  • Fixed the buttons wrapping down to the next line and looking strange on smaller screens.
Syntax.js - Syntax.js v1.5.1 - Minor fixes!

Published by williamtroup 11 months ago

  • Removed some unneeded CSS from the testing CSS file (used in the testing HTML files).
  • Fixed a security risk when injecting titles into a new window (for printing).
Syntax.js - Syntax.js v1.5.0 - Language aliases, custom buttons, and general improvements!

Published by williamtroup 11 months ago

New Features:

  • Added full language alias support (allows alias names to be added that point to a specific language name).
  • Added full custom buttons support via a new attribute called "data-syntax-buttons".

Languages:

  • Added support for the F# programming language (importable file).
  • Added support for the Rust programming language (importable file).

Public Functions:

  • Added new public function "addAlias()", which is used to add a new language alias.
  • Added new public function "removeAlias()", which is used to remove a language alias.
  • Added new public function "getAlias()", which is used to get a language alias.
  • Added new public function "getAliases()", which is used to get all language aliases.
  • Renamed the public function "getAllLanguages" to "getLanguages()".
  • Renamed the public function "getAllElementsHighlighted()" to "getElementsHighlighted()".

Documentation:

  • More documentation improvements to show how some of the new features are used.

General Improvements:

  • NUSPEC file improvements for NuGet.org submissions.

Fixes:

  • Fixed a fault that prevented the public function "removeLanguage()" from returning a valid flag when a language has been removed.
  • Fixed package description and keywords being inconsistent with the main repository.
Syntax.js - Syntax.js v1.4.0 - Unknown language, keyword casing, and more settings!

Published by williamtroup 11 months ago

Languages:

  • The binding attribute "data-syntax-language" can now be set to "unknown", which will force the layout to still be drawn, but no highlighting will be applied.
  • Added a new JSON property called "keywordsCasing", which states what casing should be used for the keywords when rendered (optional, defaults to "initial", accepts "uppercase" and "lowercase").

Binding Settings:

  • Added a new setting called "padLineNumbers", which states if the line numbers should be padded (defaults to false).

Configuration Options:

  • Added new configuration option "highlightAllDomElementTypes" (defaults to "div" and "code"), which states the element types that should be looked up when rendering.

General Improvements:

  • Double-clicking the numbers column (when enabled) will now highlight all the code in the right panel.
  • The "data-syntax-options" attribute now can accept a function name to get the required configuration.

Fixes:

  • Fixed a fault that prevented the "onKeywordClicked" custom trigger being assigned to keywords when "highlightKeywords" is set to false.

New Features:

  • Added multi-line string support for languages that support them (such as C#).
  • String searching now uses an improved RegEx for more accurate searches.
  • SafeMode support and new global library configuration options.

Public Functions:

  • Added new public function "setConfiguration()", which will set up global configuration options for the whole library.
  • The public function "getAllElementsHighlighted()" now returns a cloned version of "_elements" instead of a referenced version.
  • The public functions "getLanguage()" and "getAllLanguages()" now return a cloned version of the language objects.

Configuration Option:

  • Added new configuration option "safeMode" (defaults to true), which allows all errors to be ignored (all valid renders will still be displayed).

Languages:

  • All language files (under "dist/languages") now pass false for the "triggerRender" parameter, as the library will render automatically once the DOM is loaded.

General Improvements:

  • Removed some code that was no longer needed.
  • The numbers column can no longer have its numbers selected (CSS controlled).
  • The buttons (top right) can no longer have their text selected (CSS controlled).
  • The error log shown when a language is not available is now only shown when "safeMode" is disabled.

Documentation:

  • Renamed "OPTIONS.md" to "BINDING_OPTIONS.md" (which states all the options that can be used for the "data-syntax-options" binding attribute).
  • Added a new version of "OPTIONS.md", which is now used to show all the configurations that can be used for the public function "setConfiguration()".
  • Minor documentation updates to make things a bit clearer.

Fixes:

  • Fixed the public function "destroyAll()" reset the "_elements" variable to the wrong type.
Syntax.js - Syntax.js v1.2.0 - Printing, UI improvements, and setting improvements!

Published by williamtroup 11 months ago

New Features:

  • Printing support is now available as a configurable button (on by default).
  • A new language label is now shown in the UI to state what language is being shown.

General Improvements:

  • Redesigned the layout for the button(s) shown in the top left of the display (minor CSS class name changes), along with the new language label.
  • Added new BootStrap testing files.

Languages:

  • Added a new JSON property called "friendlyName", which states the friendly name to be shown in the language label.
  • The JSON property "keywords" now accepts either an array of strings or a space-separated string.

Settings:

  • Added a new setting called "showLanguageLabel", which states if the language label should be shown (defaults to true).
  • Added a new setting called "showPrintButton", which states if the Print button should be shown (defaults to true).
  • Added a new setting called "printButtonText", which states the text that should be shown for the new Print button (defaults to "Print").

Custom Triggers:

  • Added a new custom trigger "onPrint", which is called when the "Print" button is clicked.

Fixes:

  • Fixed the default color for "code" DOM elements reverting to the color set in Bootstrap.
Syntax.js - Syntax.js v1.1.0 - New custom triggers, performance tweaks, and fixes!

Published by williamtroup 11 months ago

General Improvements:

  • The render() method now only scans for "div" and "code" DOM element types (faster).
  • When a specific language is not supported, a new error log is shown in the console.

Custom Triggers:

  • Added new custom trigger "onKeywordRender", which is called when a keyword is rendered (before main render completion).
  • Added new custom trigger "onStringRender", which is called when a string is rendered (before main render completion).
  • Added new custom trigger "onCommentRender", which is called when a comment is rendered (before main render completion).

Documentation:

  • Fixed documentation missing references that prevented the library from working properly.
  • Improved the README.md and README_NUGET.md documentation.
Syntax.js - Syntax.js v1.0.0 - Major public function support, and language improvements!

Published by williamtroup 11 months ago

Languages:

  • Case Sensitive: Added a new language property "caseSensitive" (defaults to true) which states if the keyword matching is case sensitive.
  • Added support for the TypeScript programming language (importable file).

Settings:

  • Added a new setting called "highlightComments", which states if comments should be highlighted (defaults to true).
  • Added a new setting called "highlightStrings", which states if strings should be highlighted (defaults to true).
  • Added a new setting called "highlightKeywords", which states if keywords should be highlighted (defaults to true).

Public Functions:

  • Renamed the public function "findAndBuildNewElements()" to "highlightAll()".
  • Renamed the public function "getRenderedElements()" to "getAllElementsHighlighted()".
  • Added new public function "removeLanguage()", which will remove a specific language that can be rendered by name.
  • Added new public function "getAllLanguages()", which will return the object that contains all the language details.
  • Added new public function "highlightElement()", which will render a specific DOM element (accepts either the element or the ID of the element).
  • Added new public function "getLanguage()", which will return the details for a specific language (by name).
  • Renamed the public function "destroy()" to "destroyAll()".
  • Added a new version of the public function "destroy()", which will revert a specific element to its original HTML (minus the syntax attributes).

Custom Triggers:

  • Renamed the custom trigger "onRender" to "onRenderComplete".

UI Improvements:

  • The numbers column is now hidden by default on smaller screens (and the code line will now wrap).

Fixes:

  • Fixed links to missing documentation in the main README.md and README_NUGET.md files.
  • Fixed some grammar mistakes.
  • Fixed a fault that prevented the original destroy() public function (now destroyAll()) from clearing down the elements list.
Syntax.js - Syntax.js v0.8.0 - New settings and functions!

Published by williamtroup 11 months ago

  • Added a new setting called "showLineNumbers", which states if the line numbers should be shown (defaults to true).
  • Renamed the public function "buildNewSyntaxElements" to "findAndBuildNewElements()".
  • Added new public function "destroy()", which will revert all rendered elements to their original HTML (minus the syntax attributes).
Syntax.js - Syntax.js v0.7.0 - New languages and NuGet.org support!

Published by williamtroup 11 months ago

  • Added NuGet.org Nuget package support via a new nuspec file.
  • The default language "JavaScript" is no longer built-in, and must be imported like all other languages.
  • Updated the project description.
  • Added support for the C, JavaScript, and MS-SQL programming languages (importable files).
Syntax.js - Syntax.js v0.6.0 - Indentation support, and new languages!

Published by williamtroup 12 months ago

  • Added support for the Swift and Visual Basic programming languages (importable files).
  • Added new public function "getRenderedElements()", which returns all the elements that have been rendered.
  • Added indentation support!
  • Minor code correction for handling empty strings.
  • Added a new setting called "removeBlankLines", which states if all the blank lines should be removed (defaults to false).
  • Added some very light borders around the Numbers and Syntax DOM containers.
  • Added a default font and font size via the SCSS/CSS.
Syntax.js - Syntax.js - New custom trigger and languages!

Published by williamtroup 12 months ago

  • Added support for the C++ and Java programming languages (importable files).
  • Fixed a fault that caused parameters to be parsed for custom triggers when they were not actually set.
  • Fixed the default language containing the "*" symbol in the keywords.
  • Renamed the root variable "--color-variable" to "--color-keyword".
  • Added a new custom trigger "onKeywordClicked", which is fired when a keyword is clicked.
Syntax.js - Syntax.js v0.4.0 - New languages and better option support!

Published by williamtroup 12 months ago

  • Removed public function "setOptions()", as it's not needed due to the options attribute.
  • Removed the custom trigger "onOptionsUpdated", as it's not needed anymore.
  • Added support to set the custom triggers via the "data-syntax-options" attribute options.
  • The language property "multiLineComment" is now optional, as some languages don't require special characters for multi-line comments.
  • Added support for the Python, Go, and Ruby programming languages (importable files).
Syntax.js - Syntax.js v0.3.0 - Code/Pre support, and element options!

Published by williamtroup 12 months ago

  • Added Code/Pre element rendering support.
  • Added options attribute "data-syntax-options" support, which will override the default options per code element rendered.
  • Fixed a class name setting issue that caused a random space to appear.
  • Added a new custom trigger "onCopy", which is fired when the "Copy" button for a syntax element is pressed.
Syntax.js - Syntax.js v0.2.0 - Multi-language support, and style improvements!

Published by williamtroup 12 months ago

  • Added a border around the code container (uses root variables for easy changing).
  • Increased the padding slightly for the "Copy" button.
  • Added a background color to the code syntax container (next to the numbers) and added a border-radius.
  • Added new public function "addLanguage()", which will add a new language to the library and will auto-render DOM elements found for that language.
  • Added all missing keywords for the built-in language "JavaScript".
  • Added C# language support via an importable file.
Syntax.js - Syntax.js v0.1.0 - Everything :)

Published by williamtroup 12 months ago

  • Everything :)