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

Automatically ignore codeblocks that don't have lit-strings or line comments #75

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

dyoo
Copy link
Collaborator

@dyoo dyoo commented Sep 7, 2023

This tries to automatically omit codeblocks that don't have what looks like translatable content. For the moment, we check whether the body of a codeblock contains a """ or "//" substring, which is a heuristic for checking for literal strings or line comments.

…omments.

This tries to automatically omit codeblocks that don't have what looks
like translatable content.  For the moment, we check whether the body of
a codeblock contains a "\"" or "//" substring, which is a heuristic for
checking for literal strings or line comments.
Copy link
Collaborator

@mgeisler mgeisler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I was somehow thinking that skipping a code block would use the new mdbook-xgettext: skip comments, but I guess there's no good reason to inject those comments just to take them out a split second later.

@mgeisler
Copy link
Collaborator

mgeisler commented Sep 9, 2023

I think we should consider making this configurable at a later point. I can imagine a few settings:

  • skip all code blocks
  • skip code blocks matching a given language (the info string following the ```)
  • skip code blocks where the content matches a given set of regular expressions (such as "\"" and "//" used above)

By default, code blocks would be extracted and we should probably only add the settings we need.

Let me merge this now, then we can make a new release and test it on Comprehensive Rust for a bit.

@mgeisler mgeisler merged commit 3a6ed6a into google:main Sep 9, 2023
5 checks passed
@dyoo dyoo deleted the ignore-codeblock branch September 11, 2023 17:15
@mgeisler mgeisler changed the title Automatically ignore codeblocks that don't have lit-strings or line comments. Automatically ignore codeblocks that don't have lit-strings or line comments Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants