Skip to content

Commit

Permalink
Merge branch 'hh_ship-commonmark-fork'
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey committed Aug 31, 2023
2 parents 9175135 + 0e3ce51 commit 808f3f6
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 13 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
commonmark.js
Mattermost fork of commonmark.js
=============

This is the fork of [commonmark.js](https://github.com/commonmark/commonmark.js) used by Mattermost which includes Mattermost-specific features and some changes to the CommonMark spec. A non-exhaustive list of the changes are:
1. Made some changes to how some block elements like list items are continued (or not) after line breaks.
2. Added new features such as URL autolinking, at-mentions, hashtags, emojis, emoticons, and tables.
3. Added some fields to the AST to support new node types for the features mentioned above as well as some others introduced via transforms in the Mattermost mobile app.
4. Added integrated type definitions.

---

[![Build Status](https://github.com/commonmark/commonmark.js/workflows/CI%20tests/badge.svg)](https://github.com/commonmark/commonmark.js/actions)
[![NPM version](https://img.shields.io/npm/v/commonmark.svg?style=flat)](https://www.npmjs.org/package/commonmark)

Expand All @@ -13,6 +21,10 @@ implementations in C and JavaScript.

For more information, see <http://commonmark.org>.

(**Mattermost**) Note that we diverge from this spec in a few ways.
These will eventually be more thoroughly documented with our own
version of the spec, but that has not been done yet.

This repository contains the JavaScript reference implementation.
It provides a library with functions for parsing CommonMark
documents to an abstract syntax tree (AST), manipulating the AST,
Expand All @@ -27,7 +39,7 @@ Installing

You can install the library using `npm`:

npm install commonmark
npm install @mattermost/commonmark

This package includes the commonmark library and a
command-line executable, `commonmark`.
Expand Down Expand Up @@ -144,6 +156,10 @@ The parser returns a Node. The following public properties are defined
`html_inline`, `link`, `image`, `code`, `document`, `paragraph`,
`block_quote`, `item`, `list`, `heading`, `code_block`,
`html_block`, `thematic_break`.
- (**Mattermost**) This fork also adds `at_mention`,
`channel_link`, `emoji`, `hashtag`, `latex_inline`,
`mention_highlight`, `search_highlight`, `table`, `table_row`,
`table_cell`, `edited_indicator`, `checkbox`.
- `firstChild` (read-only): a Node or null.
- `lastChild` (read-only): a Node or null.
- `next` (read-only): a Node or null.
Expand All @@ -162,6 +178,23 @@ The parser returns a Node. The following public properties are defined
- `listTight`: `true` if list is tight.
- `listStart`: a Number, the starting number of an ordered list.
- `listDelimiter`: a String, either `)` or `.` for an ordered list.
- (**Mattermost**) `mentionName`: a String containing the
at-mentioned user/group or null.
- (**Mattermost**) `channelName`: a String containing the linked
channel or null.
- (**Mattermost**) `emojiName`: a String containing the name of
the emoji or null.
- (**Mattermost**) `hashtag`: a String containing the hashtag text
or null.
- (**Mattermost**) `latexCode`: a String containing the Latex content
of this Node or null.
- (**Mattermost**) `isChecked`: `true` if this is a checked `checkbox`.
- (**Mattermost**) `alignColumns`: if this is a `table_row`, an array of
Strings containing the alignment of each column.
- (**Mattermost**) `isHeading`: if this is a `table_row` or `table_cell`,
whether or not this is part of the first row of the table.
- (**Mattermost**) `align`: if this is a `table_cell`, the alignment of
this cell, either the empty string, `center`, `left`, or `right`.
- `onEnter`, `onExit`: Strings, used only for `custom_block` or
`custom_inline`.

Expand Down
27 changes: 26 additions & 1 deletion dist/commonmark.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* commonmark 0.30.0 https://github.com/commonmark/commonmark.js @license BSD3 */
/* commonmark 0.30.1-0 https://github.com/commonmark/commonmark.js @license BSD3 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
Expand Down Expand Up @@ -105,6 +105,7 @@
this._emojiName = null;
this._hashtag = null;
this._latexCode = null;
this._isChecked = false;

// used by tables
this._alignColumns = [];
Expand Down Expand Up @@ -259,30 +260,54 @@
get: function() {
return this._mentionName;
},
set: function(mentionName) {
this._mentionName = mentionName;
}
});

Object.defineProperty(proto, "channelName", {
get: function() {
return this._channelName;
},
set: function(channelName) {
this._channelName = channelName;
}
});

Object.defineProperty(proto, "emojiName", {
get: function() {
return this._emojiName;
},
set: function(emojiName) {
this._emojiName = emojiName;
}
});

Object.defineProperty(proto, "hashtag", {
get: function() {
return this._hashtag;
},
set: function(hashtag) {
this._hashtag = hashtag;
}
});

Object.defineProperty(proto, "latexCode", {
get: function() {
return this._latexCode;
},
set: function(latexCode) {
this._latexCode = latexCode;
}
});

Object.defineProperty(proto, "isChecked", {
get: function() {
return this._isChecked;
},
set: function(isChecked) {
this._isChecked = isChecked;
}
});

Object.defineProperty(proto, "alignColumns", {
Expand Down
2 changes: 1 addition & 1 deletion dist/commonmark.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 808f3f6

Please sign in to comment.