ryanmcalister / unotes

Unotes Visual Studio Code Extension. A markdown WYSIWYG notes editor.
MIT License
174 stars 22 forks source link

UNotes does not respect Markdownlint configuration #15

Open odonyde opened 5 years ago

odonyde commented 5 years ago

I really like the idea of this extension but I am facing a blocker using it: UNotes doesn't respect our team's style guide which we enforce via Markdownlint. For example, we have configured Markdownlint to only allow dashes to indicate unordered list items ("MD004": {"style": "dash"}). But opening an existing markdown document, UNotes converts all existing list item dashes into asterisks and thus makes the document incompliant to our style guide.

UNotes: 1.0.8
Visual Studio Code: 1.35.0 (Stable)
OS: Windows 10 Pro x64 1809 17763.529

Markdownlint Extension User Settings:
  "markdownlint.config": {
    "default": true,
    "MD003": {"style": "atx"},
    "MD004": {"style": "dash"},
    "MD007": {"indent": 4},
    "MD013": false,
    "MD026": {"punctuation": ".,;:!"},
    "MD035": {"style": "---"},
    "MD046": {"style": "fenced"}
  }
ryanmcalister commented 5 years ago

I'll see if there are some options available...

odonyde commented 5 years ago

Thanks for having a look into this! I really like how your extension eliminates the distraction by markdown symbols and allows to entirely focus on the content.

ryanmcalister commented 5 years ago

I'm experimenting with an option to have unotes auto-reformat your markdown using remark-stringify. To enable this feature, add a 'remark_settings.json' file to the .unotes folder in your project directory. All remark-stringify options can be used.

Additional Options

Example 'remark_settings.json'

    {
        "gfm": true,
        "commonmark": false,
        "pedantic": false,
        "looseTable": false,
        "spacedTable": true,
        "paddedTable": true,
        "fence": "`",
        "fences": true,
        "bullet": "-",
        "listItemIndent": "tab",
        "listItemSpace": 1,
        "listItemTabSize": 4,
        "incrementListMarker": true,
        "rule": "-",
        "ruleRepetition": 3,
        "ruleSpaces": false,
        "strong": "*",
        "emphasis": "_"
    }

Please try it out and let me know if that works for you. It's kind of experimental and I haven't fully tested everything yet... Unotes-1.0.9.vsix.zip

odonyde commented 5 years ago

Cool! Installing Unotes 1.0.9 and setting the following remark-stringify configuration solved my list item issue:

{
    "bullet": "-",
    "listItemIndent": "tab",
    "listItemSpace": 1,
    "listItemTabSize": 4
}

Unfortunately the new version also introduced two new formatting issues:

  1. Angle brackets around URLs are replaced, e.g. <https:\\example.com> is converted into &lt;https:\\example.com data-tomark-pass >
  2. Numberings of ordered lists are escaped, eg. 1. is converted into 1\.

I tried several combinations of the gfm, commonmark, pedantic, and entities flags but the above mentioned replacements persisted.

ryanmcalister commented 5 years ago

Thanks for the feedback. There appear to be some side-effects as you discovered. I'll see if I can resolve those issues...

ryanmcalister commented 5 years ago

I added a fix for the angle bracket by having remark-stringify not create angle bracket links. I'm not able to reproduce the second issue (escaped numberings). What settings produced this?

Here is an updated version. Unotes-1.0.10.vsix.zip

odonyde commented 5 years ago

Hi, Ryan! I did some testing with Unotes 1.0.10 and could delimit the escaped numberings issue: the conversion only happens for sublists with a preceding text paragraph. Example:

1. Item 1
    Some text.
    1. Item 1.1
        Some text.
    2. Item 1.2
        Some text.

is converted into

1. Item 1
    Some text.
        1\. Item 1.1
        Some text.
        2\. Item 1.2
        Some text.

This applies also for unordered sublists with a preceding text paragraph, only that here the hyphen gets converted into an underscore. Example:

- Item 1
    Some text.
    - Item 1.1
        Some text.
    - Item 1.2
        Some text.

is converted into

- Item 1
    Some text.
        _ Item 1.1
        Some text.
        _ Item 1.2
        Some text.

Regarding the angle bracket links issue: It still persists in version 1.0.10 for me and I observed that in fact any < is converted into &lt;, independent if it is part of a link or used in a comparison (e.g. A < B becomes A &lt; B).

ryanmcalister commented 5 years ago

@odonyde thanks for taking a look and giving me those examples. I removed all escape coding from the remark processing since I don't see the need for it. Let me know if this fixes the issue for you.

Unotes-1.0.11.vsix.zip

odonyde commented 5 years ago

Hi, @ryanmcalister! I took a look at Unotes 1.0.11: the moment I open file Unotes-Test.md with Unotes, it's content gets converted into the result you can see in Unotes-Test-Result-1-0-11.md.

Unotes-Test-1-0-11.zip

So version 1.0.11 resolves the escaping of < for me while the other unwanted conversions still happen.

PS: I have meanwhile updated Visual Studio Code to version 1.36.1 and I deactivated all other extensions except Unotes for the testing workspace.

ryanmcalister commented 5 years ago

unotes 1.0.14 has a fix for the 'data-tomark-pass >' issue. The other list formatting issues I have looked into, unfortunately it's a combination of the tui-editor's output and the remark formatting logic. I haven't found a good solution yet. I may have to request some features from tui-editor...

odonyde commented 5 years ago

Hi, @ryanmcalister! I can confirm that 1.0.14 fixes the data-tomark-pass > issue and now correctly converts links in angle brackets notation into inline-style links. Unfortunately it also converts any reference-style links into inline-style links. Example: The reference-style link

[example.com][ref]

[ref]: https://example.com

is converted into the inline-style link

[example.com](https://example.com)

while it simply should remain unchanged (see also Unotes-Test-Result-1-0-14.md in Unotes-Test-1-0-14.zip).

Regarding the sub-list item formatting issues: this is for sure a more complex one if it is caused by a combination of TUI Editor and remark-stringify. Although: in case TUI Editor applies any formatting changes, I would regard this as a bug on their side as the markdown should be simply left unchanged.

ryanmcalister commented 5 years ago

@odonyde Thanks for checking it out. Just an update, Unotes 1.0.15 now has the original remark-stringify behavior which keeps links unchanged except in the case when the url matches the link text. In this case it will change the inline-style link to an angle bracket link.