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

Implement recursive attributes #800

Closed
pjanx opened this issue Nov 10, 2020 · 10 comments · Fixed by #801
Closed

Implement recursive attributes #800

pjanx opened this issue Nov 10, 2020 · 10 comments · Fixed by #801
Assignees
Milestone

Comments

@pjanx
Copy link
Contributor

pjanx commented Nov 10, 2020

This must say "foobar":

:def: foo
:abc: {def}bar

{abc}

Asciidoctor makes this say "{def}bar", so it is seemingly evaluated during parsing:

:abc: {def}bar
:def: foo

{abc}

I'm trying to do doc.Attributes.GetAsStringWithDefault("mansource", "?") where the value is composed using a string passed with the -a command line option; I can't expand this string by any standard means.

@xcoulon
Copy link
Member

xcoulon commented Nov 10, 2020

@pjanx just to clarify: you expect the output to be foobar, don't you?
And yes, it seems like Asciidoctor does not support it yet.

@xcoulon
Copy link
Member

xcoulon commented Nov 10, 2020

I'm trying to do doc.Attributes.GetAsStringWithDefault("mansource", "?") where the value is composed using a string passed with the -a command line option; I can't expand this string by any standard means.

I'm not following you here. Is it related to #793?

@pjanx
Copy link
Contributor Author

pjanx commented Nov 10, 2020

I have no objections about what Asciidoctor (or AsciiDoc, haven't checked) does with attributes, things have an obvious order. The first example does not do what it should in libasciidoc yet.

The ending note was for context--what I actually want to have working: to retrieve an attribute in a renderer/backend that is expanded using attributes passed as command line options to the libasciidoc utility. Once this issue is resolved, I should be able to do that.

@xcoulon
Copy link
Member

xcoulon commented Nov 10, 2020

I have no objections about what Asciidoctor (or AsciiDoc, haven't checked) does with attributes, things have an obvious order. The first example does not do what it should in libasciidoc yet.

The ending note was for context--what I actually want to have working: to retrieve an attribute in a renderer/backend that is expanded using attributes passed as command line options to the libasciidoc utility. Once this issue is resolved, I should be able to do that.

ok, got it now. Thanks for the clarification!

@xcoulon xcoulon self-assigned this Nov 10, 2020
@xcoulon xcoulon added this to the v0.6.0 milestone Nov 10, 2020
@xcoulon
Copy link
Member

xcoulon commented Nov 10, 2020

I've added this issue in Milestone 0.6

@xcoulon
Copy link
Member

xcoulon commented Nov 11, 2020

@pjanx it should be good now:

:def: foo
:abc: {def}bar

{abc}

is now output as:

<div class="paragraph">
<p>foobar</p>
</div>

please let me know if it fixes your blocker

@pjanx
Copy link
Contributor Author

pjanx commented Nov 12, 2020

Yeah, thanks. Just. What I had in mind writing "recursive" was "recursive evaluation", which I think I've established is not what's going on (rather a 1-level expansion). And I don't know how to better name this:

Context("recursive attributes", func() {

You can still call this "attributes in attributes", to convince yourself that there is some recursion going on, though it's stretching it. "Substitutions in attribute declarations/definitions" would be lengthier but also clearly not wrong.

@xcoulon
Copy link
Member

xcoulon commented Nov 13, 2020

@pjanx indeed, recursive evaluation is not what I implemented in #801, but note that it also does not work with Asciidoc(tor) either:

:ghi: baz
:def: foo
:abc: {def{ghi}}bar

{abc}

renders as:

<div class="paragraph">
<p>{defbaz}bar</p>
</div>

ie, it does not go beyond level-1 expansion.
But you made a fair point: I should rename the context in https://github.com/bytesparadise/libasciidoc/blob/master/pkg/parser/attributes_test.go#L270 to something like "attribute substitutions in declarations" for example.

That being said, do you need a fully recursive expansion or is what I provided you with in #801 enough for you?

@pjanx
Copy link
Contributor Author

pjanx commented Nov 13, 2020

Yeah, you're paraphrasing me ("I've established" referred to the issue description). And no, there's no need for this.

@xcoulon
Copy link
Member

xcoulon commented Nov 13, 2020

Yeah, you're paraphrasing me ("I've established" referred to the issue description).

fair enough, I did not realize what you meant by "I've established", so I added my own findings/thoughts here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants