Preprocessing Markdown spec. with an extention

21 views
Skip to first unread message

Jacques Klein

unread,
Jan 11, 2022, 3:14:33 PM1/11/22
to concordion-dev
I am trying to write an extension that allows to preprocess the Markdown spec. file.

It seems that a SpecificationProcessingListener gets only called after the MarkdownConverter is done, too late to pre-process the spec. so I use a SpecificationConverter.

Three questions:

- in convert() I get testName but I also need the path of the spec. file in order to do (relative) includes in my "pre-markdown dialect", how can I find this path?.

- what is a/the good way to chain (well call in convert()) the MarkdownConverter ?

- is it possible to keep the .md suffix for my extension?, currently I am using the @Extensions(...) tag in the .java files and an other .ext, or will this "kill" the MarkdownConverter and/or it's settings?.

Thanks,
jacq

Nigel Charman

unread,
Jan 11, 2022, 3:48:40 PM1/11/22
to concord...@googlegroups.com
Hi Jacq

A couple of other options depending on the extent of the preprocessing are:
  1. Use the @ConcordionOptions annotation to add Flexmark options or Pegdown extensions if you're just wanting to extend the Markdown syntax.
  2. Wrap ClassPathSource to have access to the raw input stream and path. Use withSource(...) to implement as an extension.
Would either of these work for you?

Otherwise we may need to make a code change to allow access to the path from the SpecificationConverter.

cheers
Nigel
--
You received this message because you are subscribed to the Google Groups "concordion-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concordion-de...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/concordion-dev/a6bda68a-7e8e-4e28-bfce-717a49fd453fn%40googlegroups.com.

Jacques Klein

unread,
Jan 12, 2022, 1:57:40 PM1/12/22
to concordion-dev
Nigel, for my first question, your proposal 2. works fine. I extended ClassPathSource and did an @Override of createInputStream()

        String  specDir = Paths.get(System.getProperty("user.dir"))
                                .resolve("build/resources/test")
                                .resolve(resource.getPath().substring(1))
                                .getParent()
                               .toString();

One caveat, the use of constant "build/resources/test"

For the second and third questions, I was able to do it in an "ugly way" using reflective access to some private instance variables of the ConcordionBuilder

jac
Reply all
Reply to author
Forward
0 new messages