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

Parse "jbake-" prefixed asciidoc headers like normal metadata #580

Merged
merged 3 commits into from
Jan 19, 2019

Conversation

matthiasblaesing
Copy link
Contributor

JBake explicitly supports adding complex metadata in the form of string
encoded JSON objects. This support was missing from metadata sourced
from native asciidoc headers. The support is only added for explicit
"jbake-" headers, to not interfere with normal asciidoc operation.

JBake explicitly supports adding complex metadata in the form of string
encoded JSON objects. This support was missing from metadata sourced
from native asciidoc headers. The support is only added for explicit
"jbake-" headers, to not interfere with normal asciidoc operation.
@coveralls
Copy link

coveralls commented Jan 6, 2019

Coverage Status

Coverage increased (+0.007%) to 80.787% when pulling 20c054c on matthiasblaesing:asciidoc_inline_header into 5261a32 on jbake-org:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 80.677% when pulling 51aaa01 on matthiasblaesing:asciidoc_inline_header into 5261a32 on jbake-org:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 80.677% when pulling 51aaa01 on matthiasblaesing:asciidoc_inline_header into 5261a32 on jbake-org:master.

@ancho
Copy link
Member

ancho commented Jan 10, 2019

Interesting. Thank you. I schedule some time for a review. Maybe end of the weekend.

@ancho ancho self-requested a review January 10, 2019 07:52
Copy link
Member

@ancho ancho left a comment

Choose a reason for hiding this comment

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

Thanks for catching this. I added a few comments I would like to discuss.

content.put(key, JSONValue.parse(value));
} else {
content.put(key, value);
void processHeader(String inputKey, String inputValue, Map<String, Object> content) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm searching for a better name here. How about processHeaderValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm ok with changing the name, I used processHeader because this is key/value, an alternative would be storeHeaderValue, but I have no strong feeling into any direction.

Copy link
Member

Choose a reason for hiding this comment

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

Thats even a better name. That alignes with my attempt to build a document and template model abstraction. Which could be a new home for this method later. See #532

if(value instanceof String) {
processHeader(pKey, (String) value, documentModel);
} else {
documentModel.put(pKey, value);
Copy link
Member

Choose a reason for hiding this comment

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

We could always call processHeader. As the last case in that method adds the value for the given key to the documentModel Map. See line 284 in MarkupEngine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to special case the "String" case, as I don't want to interfere with the asciidoc engine. As NULL could be generated, we'd still need a guard as in

if(value != null) {
    processHeader(pKey, value.toString(), documentModel);
}

I have zero experience with asciidocj, so can't predict if other types, than string are possible.

Copy link
Member

Choose a reason for hiding this comment

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

Yes you are right. asciidoctorj takes a Map<Sting, Object> for attributes. So it would be worth a try. On the other hand we could postpone it for a later cleanup session.

@matthiasblaesing
Copy link
Contributor Author

I pushed two updates, that try to address the comments. I kept them separate to make review easier, for integration I would squash them.

@jonbullock jonbullock added this to the v2.6.4 milestone Jan 18, 2019
@ancho ancho merged commit 20c054c into jbake-org:master Jan 19, 2019
@jonbullock
Copy link
Member

Thanks for the contribution @matthiasblaesing 👍

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

Successfully merging this pull request may close these issues.

4 participants