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

Preprocessor line reader #32

Closed
opoudjis opened this issue Jul 10, 2024 · 4 comments
Closed

Preprocessor line reader #32

opoudjis opened this issue Jul 10, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@opoudjis
Copy link
Contributor

In https://github.com/metanorma/metanorma-standoc/blob/main/lib/metanorma/standoc/macros.rb , there is code to determine the status of a line during preprocessing of Asciidoctor, pass_status(). That code is used in the LinkProtectPreprocessor, so that lines that are passthrough or comments are not processed by that preprocessor. It needs to be made into a class, and brought into utils, so it can be shared among all line-based preprocessors; that includes metanorma-plugin-preprocessor, per metanorma/metanorma-plugin-glossarist#27

@opoudjis opoudjis added the bug Something isn't working label Jul 10, 2024
@opoudjis opoudjis self-assigned this Jul 10, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Metanorma Jul 10, 2024
@opoudjis opoudjis moved this from 🆕 New to 🏗 In progress in Metanorma Jul 10, 2024
@opoudjis
Copy link
Contributor Author

The line processing loop in preprocessors is now exemplified in the following:

    class LinkProtectPreprocessor < Asciidoctor::Extensions::Preprocessor
      def process(document, reader)
        p = Metanorma::Utils::LineStatus.new
        lines = reader.lines.map do |t|
          p.process(t)
          !p.pass && t.include?(":") and t = inlinelinkmacro(inlinelink(t))
          t
        end
        ::Asciidoctor::PreprocessorReader.new document, lines
      end

p.pass is whether the current line is to be passed through, as a preformatted line, or not. In most preprocessors, if the current line is a passthrough line, it needs to be ignored; that includes source code, passthrough, literals...

... and I've just realised: it also needs to include block comments.

@opoudjis
Copy link
Contributor Author

I'm adding this to all Preprocessors under Metanorma. @HassanAkbar That includes metanorma-plugin-glossarist

opoudjis added a commit to metanorma/metanorma-standoc that referenced this issue Jul 11, 2024
@opoudjis
Copy link
Contributor Author

Actually, no: datastruct and lutaml do need to be able to populate sourcecode and even comment text. I'm not going to insert it, at least for now, outside where I already have, the embed and link preprocessors. If we need to change that, we know where the method is.

@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Metanorma Jul 11, 2024
@opoudjis
Copy link
Contributor Author

This did debug some of the detecting of passthrough status, so it was worthwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant