<commit_before>
# Markdown Viewer / Chrome Extension

**Install: [Chrome Store][chrome-store]** / **Donate: [PayPal][paypal]**


# Features

- No special permissions required for file URLs
- Full control over the allowed origins
- Supports multiple markdown parsers
- Full control over the [compiler options][compiler-options] ([marked][marked] or [remark][remark])
- Themes support (including [GitHub theme][themes0]) ([jasonm23][themes1], [mixu][themes2], [cobalt][themes3])
- Supports [GitHub Flavored Markdown][gfm]
- Syntax highlighted code blocks ([prism][prism])
- Generates Table of Contents (TOC)
- Remembers scroll position
- Emoji support (Icons provided free by [EmojiOne][emojione])
- [MathJax][mathjax] support
- Settings synchronization
- Raw and rendered markdown views
- Free and Open Source


# Table of Contents

- **[After Install](#after-install)**
  - [Local Files](#local-files)
  - [Remote Files](#remote-files)
- [Compiler Options](#compiler-options)
  - [Marked](#marked)
  - [Remark](#remark)
- [Content Options](#content-options)
  - [Scroll](#scroll)
  - [TOC](#toc)
  - [MathJax](#mathjax)
  - [Emoji](#emoji)
- [Advanced Options](#advanced-options)
  - [Add Origin](#add-origin)
  - [Add All Origins](#add-all-origins)
  - [Header Detection](#header-detection)
  - [Path Matching](#path-matching)
  - [Remove Origin](#remove-origin)
  - [Refresh Origin](#refresh-origin)
- [Markdown Syntax and Features](#markdown-syntax-and-features)
- [More Compilers](#more-compilers)


# After Install

## Local Files

1. Navigate to `chrome://extensions`
2. Make sure that the `Allow access to file URLs` checkbox is checked for the Markdown Viewer extension

![file-urls]


## Remote Files

1. Click on the Markdown Viewer icon and select [Advanced Options](#advanced-options)
2. Add the origins that you want enabled for the Markdown Viewer extension


# Compiler Options

## Marked

Option          | Default | Description
:---            | :---    | :---
**breaks**      | `false` | Enable GFM [line breaks][gfm]. This option requires the gfm option to be true.
**gfm**         | `true`  | Enable GFM [GitHub Flavored Markdown][gfm].
**pedantic**    | `false` | Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
**sanitize**    | `false` | Sanitize the output. Ignore any HTML that has been input.
**smartLists**  | `false` | Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
**smartypants** | `false` | Use "smart" typographic punctuation for things like quotes and dashes.
**tables**      | `true`  | Enable GFM [tables][gfm-tables]. This option requires the gfm option to be true.

## Remark

Option          | Default | Description
:---            | :---    | :---
**breaks**      | `false` | Enable GFM [line breaks][gfm]. This option requires the gfm option to be true.
**commonmark**  | `false` | Toggle CommonMark mode.
**footnotes**   | `false` | Toggle reference footnotes and inline footnotes.
**gfm**         | `true`  | Enable GFM [GitHub Flavored Markdown][gfm].
**pedantic**    | `false` | Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
**sanitize**    | `false` | Sanitize the output. Ignore any HTML that has been input.


# Content Options

Option          | Default | Description
:---            | :---    | :---
**emoji**       | `false` | Convert emoji :shortnames: into EmojiOne images
**scroll**      | `true`  | Remember scroll position
**toc**         | `false` | Generate Table of Contents
**mathjax**     | `false` | Render TeX and LaTeX math blocks

## Scroll

- When enabled, the `scroll` option remembers the current scroll position and scrolls back to it after page load.
- When disabled, the `scroll` option either scrolls to the top of the document or to a certain header (anchor) if a hash URL fragment is present.

## TOC

- Generates Table of Contents (TOC) based on the headers found in the markdown document.

## MathJax

The following `mathjax` delimiters are supported:

- inline math: `\(math\)` and `$math$`
- display math: `\[math\]` and `$$math$$`

The following rules apply to your content when `mathjax` is enabled:

- Regular dollar sign `$` in text that is not part of a math formula should be escaped: `\$`
- Regular markdown escaping for parentheses: `\(` and `\)`, and brackets: `\[` and `\]` is not supported. MathJax will convert anything between these delimiters to math formulas, unless they are wrapped in backticks: `` `\(` `` or fenced code blocks.

> The MathJax support currently works only for local file URLs and remote origins without strict *Content Security Policy (CSP)* set. For example it won't work for files hosted on GitHub.

## Emoji

- Emoji shortnames like: `:sparkles:` will be converted to :sparkles: using [EmojiOne][emojione] images.
- Currently unicode symbols like `✨` and ASCII emoji like `:D` are not supported.

> The Emoji support currently works only for local file URLs and remote origins without strict *Content Security Policy (CSP)* set. For example it won't work for files hosted on GitHub.


# Advanced Options

Detecting and rendering [local file URLs](#local-files) can be enabled by using the `Allow access to file URLs` option for the extension.

Access to remote URLs however, needs to be enabled manually.


## Add Origin

Here is how you can enable the extension for the `https://raw.githubusercontent.com` origin:

![add-origin]

The origin consists of *protocol* part and *domain* part. The *protocol* can be either `https`, `http`, or a `*` to match both `https` and `http`.

Enable the above origin and play around with the extension options [here][syntax].

## Add All Origins

In case you really want to you can enable the extension for **all** origins:

![all-origins]

Alternatively you can use the `Allow All` button.

> Note that the remote origins should either provide a valid HTTP header (see [Header Detection](#header-detection)) and/or valid URL path (see [Path Matching](#path-matching)). Otherwise you'll have to add the origin explicitly and set its [Path Matching](#path-matching) regular expression.

## Header Detection

When this option is enabled the extension will check for the `text/markdown` and `text/x-markdown` *content-type* header before trying to match the path:

![header-detection]

## Path Matching

If the header detection is disabled or a proper *content-type* header is missing, the extension will check if the URL is ending with a markdown file extension:

![path-regexp]

It's a simple regular expression that matches URLs ending with:

- markdown file extension: `\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)`
- and optionally anchor or querystring after that: `(?:#.*|\?.*)?`

> The `?:` used in `(?:match)` stands for *non-capturing group* and it's there for performance reasons.

You can modify the path matching regular expression for each enabled origin individually. The settings are being updated as you type.

## Remove Origin

At any point click on the small `x` button next to the origin that you want to remove. This actually removes the permission itself so that the extension is no longer able to inject scripts into that origin.

Note that the Chrome's consent popup shows up only when you add the origin for the first time. In case you re-add it you'll no longer see that popup. That's a Chrome thing and it's not controllable through the extension.

## Refresh Origin
<commit_msg>Update docs<commit_after>
# Markdown Viewer / Chrome Extension

**Install: [Chrome Store][chrome-store]** / **Donate: [PayPal][paypal]**


# Features

- No special permissions required for file URLs
- Full control over the allowed origins
- Supports multiple markdown parsers
- Full control over the [compiler options][compiler-options] ([marked][marked] or [remark][remark])
- Themes support (including [GitHub theme][themes0]) ([jasonm23][themes1], [mixu][themes2], [cobalt][themes3])
- Supports [GitHub Flavored Markdown][gfm]
- Syntax highlighted code blocks ([prism][prism])
- Generates Table of Contents (TOC)
- Remembers scroll position
- Emoji support (Icons provided free by [EmojiOne][emojione])
- [MathJax][mathjax] support
- Settings synchronization
- Raw and rendered markdown views
- Free and Open Source


# Table of Contents

- **[After Install](#after-install)**
  - [Local Files](#local-files)
  - [Remote Files](#remote-files)
- [Compiler Options](#compiler-options)
  - [Marked](#marked)
  - [Remark](#remark)
- [Content Options](#content-options)
  - [Scroll](#scroll)
  - [TOC](#toc)
  - [MathJax](#mathjax)
  - [Emoji](#emoji)
- [Advanced Options](#advanced-options)
  - [Add Origin](#add-origin)
  - [Add All Origins](#add-all-origins)
  - [Exclude Domains](#exclude-domains)
  - [Header Detection](#header-detection)
  - [Path Matching](#path-matching)
  - [Remove Origin](#remove-origin)
  - [Refresh Origin](#refresh-origin)
- [Markdown Syntax and Features](#markdown-syntax-and-features)
- [More Compilers](#more-compilers)


# After Install

## Local Files

1. Navigate to `chrome://extensions`
2. Make sure that the `Allow access to file URLs` checkbox is checked for the Markdown Viewer extension

![file-urls]


## Remote Files

1. Click on the Markdown Viewer icon and select [Advanced Options](#advanced-options)
2. Add the origins that you want enabled for the Markdown Viewer extension


# Compiler Options

## Marked

Option          | Default | Description
:---            | :---    | :---
**breaks**      | `false` | Enable GFM [line breaks][gfm]. This option requires the gfm option to be true.
**gfm**         | `true`  | Enable GFM [GitHub Flavored Markdown][gfm].
**pedantic**    | `false` | Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
**sanitize**    | `false` | Sanitize the output. Ignore any HTML that has been input.
**smartLists**  | `false` | Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
**smartypants** | `false` | Use "smart" typographic punctuation for things like quotes and dashes.
**tables**      | `true`  | Enable GFM [tables][gfm-tables]. This option requires the gfm option to be true.

## Remark

Option          | Default | Description
:---            | :---    | :---
**breaks**      | `false` | Enable GFM [line breaks][gfm]. This option requires the gfm option to be true.
**commonmark**  | `false` | Toggle CommonMark mode.
**footnotes**   | `false` | Toggle reference footnotes and inline footnotes.
**gfm**         | `true`  | Enable GFM [GitHub Flavored Markdown][gfm].
**pedantic**    | `false` | Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
**sanitize**    | `false` | Sanitize the output. Ignore any HTML that has been input.


# Content Options

Option          | Default | Description
:---            | :---    | :---
**emoji**       | `false` | Convert emoji :shortnames: into EmojiOne images
**scroll**      | `true`  | Remember scroll position
**toc**         | `false` | Generate Table of Contents
**mathjax**     | `false` | Render TeX and LaTeX math blocks

## Scroll

- When enabled, the `scroll` option remembers the current scroll position and scrolls back to it after page load.
- When disabled, the `scroll` option either scrolls to the top of the document or to a certain header (anchor) if a hash URL fragment is present.

## TOC

- Generates Table of Contents (TOC) based on the headers found in the markdown document.

## MathJax

The following `mathjax` delimiters are supported:

- inline math: `\(math\)` and `$math$`
- display math: `\[math\]` and `$$math$$`

The following rules apply to your content when `mathjax` is enabled:

- Regular dollar sign `$` in text that is not part of a math formula should be escaped: `\$`
- Regular markdown escaping for parentheses: `\(` and `\)`, and brackets: `\[` and `\]` is not supported. MathJax will convert anything between these delimiters to math formulas, unless they are wrapped in backticks: `` `\(` `` or fenced code blocks.

> The MathJax support currently works only for local file URLs and remote origins without strict *Content Security Policy (CSP)* set. For example it won't work for files hosted on GitHub.

## Emoji

- Emoji shortnames like: `:sparkles:` will be converted to :sparkles: using [EmojiOne][emojione] images.
- Currently unicode symbols like `✨` and ASCII emoji like `:D` are not supported.

> The Emoji support currently works only for local file URLs and remote origins without strict *Content Security Policy (CSP)* set. For example it won't work for files hosted on GitHub.


# Advanced Options

Detecting and rendering [local file URLs](#local-files) can be enabled by using the `Allow access to file URLs` option for the extension.

Access to remote URLs however, needs to be enabled manually.


## Add Origin

Here is how you can enable the extension for the `https://raw.githubusercontent.com` origin:

![add-origin]

The origin consists of *protocol* part and *domain* part. The *protocol* can be either `https`, `http`, or a `*` to match both `https` and `http`.

Enable the above origin and play around with the extension options [here][syntax].

## Add All Origins

In case you really want to you can enable the extension for **all** origins:

![all-origins]

Alternatively you can use the `Allow All` button.

> Note that the remote origins should either provide a valid HTTP header (see [Header Detection](#header-detection)) and/or valid URL path (see [Path Matching](#path-matching)). Otherwise you'll have to add the origin explicitly and set its [Path Matching](#path-matching) regular expression.

## Exclude Domains

When you enable the extension for all origins, a new `Excluded Domains` section will become available in the options page.

When the extension is enabled for all origins, it will try to inject itself into all pages with URLs ending with markdown file extension using the [Path Matching](#path-matching) for the `*://*` origin.

However a few websites are known to serve pages with URLs ending with markdown file extension, but instead of a raw markdown they serve a rendered HTML there. For example: https://github.com/simov/markdown-viewer/blob/master/README.md

When you enable the extension for all origins you get a list of domains excluded by default: `bitbucket.org`, `getcomposer.org`, `github.com`, `gitlab.com`, however you can extend/modify that list as you want.

## Header Detection

When this option is enabled the extension will check for the `text/markdown` and `text/x-markdown` *content-type* header before trying to match the path:

![header-detection]

## Path Matching

If the header detection is disabled or a proper *content-type* header is missing, the extension will check if the URL is ending with a markdown file extension:

![path-regexp]

It's a simple regular expression that matches URLs ending with:

- markdown file extension: `\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)`
- and optionally anchor or querystring after that: `(?:#.*|\?.*)?`

> The `?:` used in `(?:match)` stands for *non-capturing group* and it's there for performance reasons.

You can modify the path matching regular expression for each enabled origin individually. The settings are being updated as you type.

## Remove Origin

At any point click on the small `x` button next to the origin that you want to remove. This actually removes the permission itself so that the extension is no longer able to inject scripts into that origin.

Note that the Chrome's consent popup shows up only when you add the origin for the first time. In case you re-add it you'll no longer see that popup. That's a Chrome thing and it's not controllable through the extension.

## Refresh Origin

{'fraction_non_alphanumeric': 0.10780947624695673, 'fraction_numerical': 0.0012485173856045945, 'mean_word_length': 4.03140703517588, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1387185', 'n_tokens_mistral': 4661, 'n_tokens_neox': 4421, 'n_words': 2023}