Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown syntax check #2495

Closed
nijel opened this issue Jan 17, 2019 · 17 comments
Closed

Markdown syntax check #2495

nijel opened this issue Jan 17, 2019 · 17 comments
Assignees
Labels
enhancement Adding or requesting a new feature.
Milestone

Comments

@nijel
Copy link
Member

nijel commented Jan 17, 2019

Is your feature request related to a problem? Please describe.
Many projects use Weblate to edit text files using markdown (and extracted through po4a).

Describe the solution you'd like
Weblate should provide quality check for markdown markup.

Additional context
Example project can be seen at https://hosted.weblate.org/projects/f-droid/website-posts/

Example po file: https://gitlab.com/fdroid/fdroid-website/blob/master/po/_posts.cs.po

@nijel nijel added the enhancement Adding or requesting a new feature. label Jan 17, 2019
@emmapeel2
Copy link
Contributor

someone mentioned https://github.com/MihaZupan/MarkdownValidator

@eighthave
Copy link
Contributor

I have a very basic script that check links in Markdown. I could probably port those to Weblate checks pretty easily. But a more complete solution would be nicer. Here is my script:

@matrixcoffee FYI

@nijel nijel self-assigned this Jan 26, 2019
nijel added a commit that referenced this issue Feb 7, 2019
Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
nijel added a commit that referenced this issue Feb 7, 2019
Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
nijel added a commit that referenced this issue Feb 7, 2019
It does check whether link references match source.

Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
nijel added a commit that referenced this issue Feb 7, 2019
Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
@nijel nijel closed this as completed in b878711 Feb 7, 2019
@nijel
Copy link
Member Author

nijel commented Feb 7, 2019

Thank you for your report, the issue you have reported has just been fixed. I've implemented checks which I think make sense (links, link references and inline markup).

  • In case you see problem with the fix, please comment on this issue.
  • In case you see similar problem, please open separate issue.
  • If you are happy with the outcome, consider supporting Weblate by donating.

@nijel nijel added this to the 3.5 milestone Feb 7, 2019
nijel added a commit that referenced this issue Feb 7, 2019
Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
@sajolida
Copy link

Hi @nijel, I'm really happy to see this implemented!

I'm not really good at reading Python, so can you clarify if these checks cover, for example, missing or extra * for bold and italic?

For example:

  • Good Markdown: This is **bold** and this is *italic*.
  • Bad Markdown: This **bold* is broken.

@nijel
Copy link
Member Author

nijel commented Feb 15, 2019

So far it does check if markup in translation is same as in source.

@sajolida
Copy link

Of course! This sounds like an excellent approach :)

@eighthave
Copy link
Contributor

One thing I see a lot in translations is a space between ] and ( that breaks the Markdown link syntax, e.g. '[Použij Weblate] (https://weblate.org/). That would be a good test case to have for this.

nijel added a commit that referenced this issue Feb 15, 2019
Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
@nijel
Copy link
Member Author

nijel commented Feb 15, 2019

It does catch this (just to be sure, I've just added this to the testsuite).

@eighthave
Copy link
Contributor

The other one that I see quite commonly is that translators translate the strings in the URL portion of the Markdown link. That of course breaks the link. That's also in https://gitlab.com/fdroid/fdroid-website/blob/1.72/tools/check-page-links.py Basically, I store all links that are in the source string, then for each link found in the translation string, I check to make sure it is in the list of source string links.

@eighthave
Copy link
Contributor

The hard part with that check is that some sites might want to change all links to force the page to use the localized version, but I haven't seen that case in the stuff I've worked out.

@nijel
Copy link
Member Author

nijel commented Feb 21, 2019

Currently it doesn't trigger on changed URL, exactly for reason that it might be valid to change them to locale specific in some cases.

@eighthave
Copy link
Contributor

On our site, we almost always use relative links for internal links, then the locale is inherited from the page, and doesn't need to be in the actual link itself. I think this is a relatively common setup for localized websites. And so far, no one has found a localized link for any of the external links that are included.

@emmapeel2
Copy link
Contributor

With ikiwiki most of the links are locale-agnostic, but the inlines need to be changed (add the locale at the end as .es with Spanish)

@nijel
Copy link
Member Author

nijel commented Feb 22, 2019

Okay, maybe it makes sense to check relative links for being same.

nijel added a commit that referenced this issue Feb 22, 2019
Check that relative or page anchors are same. We still do not check
external links.

Issue #2495

Signed-off-by: Michal Čihař <[email protected]>
@marcbria
Copy link

marcbria commented Dec 3, 2019

Sorry @nijel is this included in last weblate relase?
In other words, is weblate markdown ready?

@nijel
Copy link
Member Author

nijel commented Dec 3, 2019

What do you mean by "markdown ready"? It can validate markdown syntax in the strings, it can not parse markdown files, see #3106

@marcbria
Copy link

marcbria commented Dec 4, 2019

I was asking if is able to work with ".md" files, so you answered my question.
Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants