tritondatacenter / node-jiramark Goto Github PK
View Code? Open in Web Editor NEWA node library for parsing JIRA markup
License: Mozilla Public License 2.0
A node library for parsing JIRA markup
License: Mozilla Public License 2.0
JIRA has markup for tables. The library should have support for it.
Non-breaking spaces (U+00A0) should be treated like regular spaces, and leading newlines should be allowed at the start of a document.
While testing out this library in bugview, I found that the parser took an extremely long time to finish processing MANTA-3707. After some experimentation, it seems that the issue is largely a consequence of visiting characters one at a time, and generating a new node for each character.
After trying out several other libraries, I decided to build something on top of Ohm to help speed it up. With my changes, representative regular expressions get propagated up the rule definition where possible, so that it can be quickly accepted or rejected when applied. For rules that are accepted, we generate a thunk node that can be split up into the other representative nodes later on when visited. This allows us to avoid building a large number of nodes for the contents of {noformat}
/{code}
blocks, where we're just going to use the .sourceString
property, and not actually visit any of its contents. (The same goes for lines in paragraphs that contain no special characters.)
I noticed that the bugview server got stuck parsing OS-7093. Upon closer inspection realized it was because it had markup like this:
| A | - | - |
| B | - | - |
When the parser first encounts the -
, it thinks that it needs to parse a list. When it then encounters the |
, it thinks that it's parsing a table inside a list element, rather than closing the table.
It's okay to open up blocks inside a line, and the parser should accept it. Some example tickets include:
{code}
is used in a list item, after some text{noformat}
is used in a list item, after some text{color}
is used in a commentI'm not sure what fixing this looks like yet, but the following currently gets processed incorrectly:
Run {{cmd -C --long}}
This should produce <p>Run <code>cmd -C --long</code>
, but it instead turns into <p>Run <code>cmd <del>C </del>-long</code></p>
, since the dashes are treated as strikethrough markup.
JIRA markup has special syntax for creating links to issue attachments, [foo|^filename]
. See for example MANTA-4053. There's also the !foo.png!
syntax for embedding images (and other filetypes) in an issue. See for example MANTA-3803.
When using the bracket syntax to create a link ([uri]
or [text|uri]
), the text is only treated as markup when:
http
, https
, ftp
, mailto
, file
, and irc
. Others, like tel
for telephone numbers or news
for newsgroups don't seem to be recognized//
(e.g. //example.com/path/resource.txt
)#
(e.g. #fragment
)When none of these are the case, then the input text is treated as literal characters instead of as a link. See the commit message at the end of OS-7498 for an example of this.
{noformat}
, {code}
, and {panel}
support an option "title"
, which set a header at the top of the block. This was requested in TritonDataCenter/bugview#29, so it would be nice to add support here so that it can be resolved once bugview uses this library.
Despite having block syntax, JIRA actually treats {color}
as formatting syntax instead. It doesn't generate a colored block, but rather wraps text with the <font>
tag. Since the <font>
tag in considered deprecated, I'm going to make it generate the <span>
tag instead when I fix this.
Input like The results are ~5 and ~7
currently get formatted as subscript, but shouldn't be. Because what would be the closing format character is followed by an alphanumeric character, it's not actually interpreted as formatting..
There are some edge cases that the first release didn't handle:
bq.
There's also some additional markup that people frequently use in JIRA that would be useful to implement:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.