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

Fix RawString issue with Asciidoc and Markdown template extensions #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
import java.util.List;
import java.util.concurrent.CompletionStage;

import io.quarkus.qute.CompletedStage;
import io.quarkus.qute.EngineConfiguration;
import io.quarkus.qute.ResultNode;
import io.quarkus.qute.SectionHelper;
import io.quarkus.qute.SectionHelperFactory;
import io.quarkus.qute.SingleResultNode;
import io.quarkus.qute.TemplateExtension;
import io.quarkus.qute.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls don't use wildcards for imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix it tomoz


@EngineConfiguration
public class AsciidocSectionHelperFactory
Expand All @@ -29,8 +23,8 @@ public AsciidocSectionHelper initialize(SectionInitContext context) {
}

@TemplateExtension(matchNames = { "asciidocify", "asciidocToHtml" })
static String convertToAsciidoc(String text, String ignoredName) {
return CONVERTER.apply(text);
static RawString convertToAsciidoc(String text, String ignoredName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How does it fix the problem with section params in #146?

IIUIC this merely changes the behavior of {text.asciidocToHtml} in a way that it corresponds to {text.asciidocToHtml.raw}. Which is probably ok, unless someone wants to escape the result of conversion... which probably does not make a lot of sense, right?

Copy link
Member

Choose a reason for hiding this comment

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

What I was trying to achieve with an attribute was to prevent the the rendered content of beeing escaped. So if we have another to achieve the same it's fine.
It may be still be of some use to be able to pass attributes to the section but this would be a good start.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does it fix the problem with section params in #146?

IIUIC this merely changes the behavior of {text.asciidocToHtml} in a way that it corresponds to {text.asciidocToHtml.raw}. Which is probably ok, unless someone wants to escape the result of conversion... which probably does not make a lot of sense, right?

Yes that's why we make it the default behaviour, it doesn't make sense to use it escaped..

return new RawString(CONVERTER.apply(text));
}

public static class AsciidocSectionHelper implements SectionHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
import java.util.List;
import java.util.concurrent.CompletionStage;

import io.quarkus.qute.*;
import jakarta.inject.Inject;

import io.quarkus.arc.Arc;
import io.quarkus.arc.impl.LazyValue;
import io.quarkus.qute.CompletedStage;
import io.quarkus.qute.EngineConfiguration;
import io.quarkus.qute.ResultNode;
import io.quarkus.qute.SectionHelper;
import io.quarkus.qute.SectionHelperFactory;
import io.quarkus.qute.SingleResultNode;
import io.quarkus.qute.TemplateExtension;

@EngineConfiguration
public class MarkdownSectionHelperFactory
Expand Down Expand Up @@ -47,8 +41,8 @@ public MarkdownSectionHelper initialize(SectionInitContext context) {
() -> Arc.container().instance(MdConverter.class).get());

@TemplateExtension(matchNames = { "markdownify", "mdToHtml" })
static String convertToMarkdown(String text, String ignoredName) {
return CONVERTER.get().html(text);
static RawString convertToMarkdown(String text, String ignoredName) {
return new RawString(CONVERTER.get().html(text));
}

public static class MarkdownSectionHelper implements SectionHelper {
Expand Down
Loading