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

Abbreviation node not called when 2 abbreviations #27

Closed
vmassol opened this issue Dec 25, 2016 · 5 comments
Closed

Abbreviation node not called when 2 abbreviations #27

vmassol opened this issue Dec 25, 2016 · 5 comments

Comments

@vmassol
Copy link

vmassol commented Dec 25, 2016

Hi, I'm now adding support for MD abbreviations.

I have added the AbbreviationExtension and registered a handler:

        AbbreviationNodeVisitor abbreviationNodeVisitor = new AbbreviationNodeVisitor(this.visitor, this.listeners);
        this.visitor.addHandlers(
            new VisitHandler<>(Abbreviation.class, abbreviationNodeVisitor::visit)
        );

And in my visit method:

    public void visit(Abbreviation node)
    {
        // Since XWiki doesn't support abbreviations, we generate an HTML <abbr> element.
        String html;
        if (StringUtils.isNotEmpty(node.getAbbreviation())) {
            html = String.format("<abbr title=\"%s\">%s</abbr>", node.getAbbreviation(),
                String.valueOf(node.getChars()));
        } else {
            html = String.format("<abbr>%s</abbr>", String.valueOf(node.getChars()));
        }
        getListener().onRawText(html, Syntax.HTML_4_01);
    }

The problem comes from the following input:

The HTML specification is maintained by the W3C.

*[HTML]: Hyper Text Markup Language
*[W3C]:  World Wide Web Consortium

In my case I get only 1 call for my visit(Abbreviation node)method instead of the 2 I was expecting.

In other words, I don't get a call for the W3Cabbreviation.

Any idea?

Thanks again!

@vmassol
Copy link
Author

vmassol commented Dec 25, 2016

ok I know why.

with the following input it works fine:

The HTML specification is maintained by the W3C.

*[HTML]: Hyper Text Markup Language
*[W3C]:  World Wide Web Consortium

So the issue is the trailing newline. With pegdown it was working without a trailing newline. Could you confirm if the currently implemented behavior is correct (i.e. to not consider an abbreviation definition if it's not ending with a newline even if if that last line of the input?

Thanks

@vsch
Copy link
Owner

vsch commented Dec 26, 2016

@vmassol, it should accept the abbreviation definition without a trailing EOL at the end of the file. If it does not then it is a bug. I will add a test and fix it.

@vsch vsch added the 🪲 bug label Dec 26, 2016
@vsch
Copy link
Owner

vsch commented Dec 26, 2016

@vmassol, confirmed and fixed. Are you using maven or this repo for your project. If its maven I will do a release, otherwise I will just update the repo and wait for more fixes before making an official release.

@vmassol
Copy link
Author

vmassol commented Dec 26, 2016

cool. Yes I'm using Maven. I can wait a few days if you don't want to release a new version now.

@vsch
Copy link
Owner

vsch commented Dec 26, 2016

@vmassol, maven released. Not a problem to release it. If you were not using it then there would be no point in making a release.

Thank you for catching this one. All previous tests were done with an EOL at the end of the file. I will modify the testing to make No trailing EOL the default for all tests.

Thilo-Acrolinx pushed a commit to Kijimuna/flexmark-java that referenced this issue Aug 22, 2024
…vsch#27)

Bumps [org.apache.maven.plugins:maven-deploy-plugin](https://github.com/apache/maven-deploy-plugin) from 2.8.2 to 3.1.2.
- [Release notes](https://github.com/apache/maven-deploy-plugin/releases)
- [Commits](apache/maven-deploy-plugin@maven-deploy-plugin-2.8.2...maven-deploy-plugin-3.1.2)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-deploy-plugin
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants