Skip to main content

Highlight.js-based syntax highlighting for web pages built with markyp-html

Project description

Build Status Downloads Downloads Downloads

markyp-highlightjs

Highlight.js-based syntax highlighting for web pages built with markyp-html.

Installation

The project is listed on the Python Package Index, it can be installed simply by executing pip install markyp-highlightjs.

Getting started

If you are not familiar with the basic concepts of markyp, please start by having a look at its documentation here.

The following code shows the creation of a simple webpage that displays syntax highlighted Python code. There are three things to note in the example:

  • The selected theme (CSS) is added to the head of the document.
  • The syntax highlighted code is created using the highlight() method.
  • The JavaScript code that imports and initializes Highlight.js is added to the javascript section of the page.
from markyp_html import webpage
from markyp_highlightjs import js, themes, highlight

code = "\n".join([
    "from markyp_html import webpage",
    "from markyp_highlightjs import js, themes, highlight",
    "page = webpage(",
    "    highlight(\"import antigravity\", language=\"python\"),",
    "    page_title=\"markyp-highlightjs demo page\",",
    "    head_elements=[themes.darcula],",
    "    javascript=js.js",
    ")",
    "",
    "print(page)"
])

page = webpage(
    highlight(code, language="python"),
    page_title="markyp-highlightjs demo page",
    head_elements=[themes.github],
    javascript=js.js
)

print(page)

For more details on how this package works, please see markyp and markyp-html.

Community guidelines

In general, please treat each other with respect and follow the below guidelines to interact with the project:

  • Questions, feedback: Open an issue with a [Question] <issue-title> title.
  • Bug reports: Open an issue with a [Bug] <issue-title> title, an adequate description of the bug, and a code snippet that reproduces the issue if possible.
  • Feature requests and ideas: Open an issue with an [Enhancement] <issue-title> title and a clear description of the enhancement proposal.

Contribution guidelines

Every form of contribution is welcome, including documentation improvements, tests, bug fixes, and feature implementations.

Please follow these guidelines to contribute to the project:

  • Make sure your changes match the documentation and coding style of the project, including PEP 484 type annotations.
  • mypy is used to type-check the codebase, submitted code should not produce typing errors. See this page for more information on mypy.
  • Small fixes can be submitted simply by creating a pull request.
  • Non-trivial changes should have an associated issue in the issue tracker that commits must reference (typically by adding #refs <issue-id> to the end of commit messages).
  • Please write tests for the changes you make (if applicable).

If you have any questions about contributing to the project, please contact the project owner.

As mentioned in the contribution guidelines, the project is type-checked using mypy, so first of all, the project must pass mypy's static code analysis.

The project is tested using pytest. The chosen test layout is that tests are outside the application code, see this page for details on what it means in practice.

If pytest is installed, the test set can be executed using the pytest test command from within the project directory.

If pytest-cov is also installed, a test coverage report can be generated by executing pytest test --cov markyp_highlightjs from the root directory of the project.

License - MIT

The library is open-sourced under the conditions of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markyp-highlightjs-0.1910.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

markyp_highlightjs-0.1910.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file markyp-highlightjs-0.1910.0.tar.gz.

File metadata

  • Download URL: markyp-highlightjs-0.1910.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.3

File hashes

Hashes for markyp-highlightjs-0.1910.0.tar.gz
Algorithm Hash digest
SHA256 0fd70f73e7b5cd85449909e51424e31cab9e3dfd6ebef1e36ad415b42a633755
MD5 85c00711e3533769fbb4af8ccd47790e
BLAKE2b-256 1c7f6edd49a9fd47cae30067162e67e8161100b06754679956f26d63f605828a

See more details on using hashes here.

File details

Details for the file markyp_highlightjs-0.1910.0-py3-none-any.whl.

File metadata

  • Download URL: markyp_highlightjs-0.1910.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.3

File hashes

Hashes for markyp_highlightjs-0.1910.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24e098d7d095a025a2d7bd975c406ab51b3421dfd37fe5b911924126a7033e43
MD5 09fce59ee397663023a5c7ea3f6f5e4f
BLAKE2b-256 30be2f8d757a2b52f4321384acf1e27ae3634abb95bde7f2c4d753e4b4189cda

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page