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

Make Raw Content available for titles and content-parts #1146

Open
jexp opened this issue Oct 13, 2014 · 8 comments
Open

Make Raw Content available for titles and content-parts #1146

jexp opened this issue Oct 13, 2014 · 8 comments
Assignees
Milestone

Comments

@jexp
Copy link

jexp commented Oct 13, 2014

When accessing the title of a document or section it is already rendered to HTML
(I found an unrendered version in the attributes)

The same is true for ContentPart content, so I cannot access the original text. Which is important if for instance that content is code that I want to run :)

The discussion should be about the APIs.

I could imagine, like in doucument.getTitle() that you get an (lazily populated) Content-object back that has methods like:

  • getAsciiDoc() / getRaw()
  • getHtml() / getRendered()
  • there could be additional metadata attached to that "content-object"
@mojavelinux
Copy link
Member

The reason this is a challenge is because we want to keep the converters / backends simply by allowing the call to node.title. At one point, I considered adding node.raw_title, but it felt very hackish.

As for the content, you can access that already using several methods:

  • lines (returns array of raw source lines)
  • source (returns string of raw source lines)

These just aren't mapped right in AsciidoctorJ.

I think the only time we are converting on access is the title.

The open question is, what should the API look like to get the raw title instead of the converted title? Perhaps it should be something like "metadata" which would contain the raw title source.

@lordofthejars
Copy link
Member

I will open an issue to AsciidoctorJ to implement these missing methods.

2014-10-13 9:46 GMT+02:00 Dan Allen notifications@github.com:

The reason this is a challenge is because we want to keep the converters /
backends simply by allowing the call to node.title. At one point, I
considered adding node.raw_title, but it felt very hackish.

As for the content, you can access that already using several methods:

  • lines (returns array of raw source lines)
  • source (returns string of raw source lines)

These just aren't mapped right in AsciidoctorJ.

I think the only time we are converting on access is the title.

The open question is, what should the API look like to get the raw title
instead of the converted title? Perhaps it should be something like
"metadata" which would contain the raw title source.


Reply to this email directly or view it on GitHub
#1146 (comment)
.

+----------------------------------------------------------+
Alex Soto Bueno - Computer Engineer
www.lordofthejars.com
+----------------------------------------------------------+

@mojavelinux
Copy link
Member

Thanks @lordofthejars!

@mojavelinux mojavelinux modified the milestones: v1.5.4, v1.5.3 Jul 10, 2015
@mojavelinux mojavelinux modified the milestones: v1.5.4, v1.6.0 Dec 21, 2015
@mojavelinux
Copy link
Member

We have the same problem with ListItem. There needs to be a way to access to read the raw text.

For now, this content can be accessed using instance_variable_get. For example:

list_item = ...
list_item.instance_variable_get :@text

We just need to work out the public API.

@mojavelinux
Copy link
Member

This came up again, and it got me thinking that the right terminology might be title_source (for regular blocks) and text_source (for list items). That is parallel with source, which gives you the source of a delimited block (without the delimiter lines). Another possible name would be title_line and text_line, respectively, but I'm less convinced about that. Either way, I don't really like the term "raw".

@Alwinator
Copy link

It would be very convenient, and I would need this feature too, to resolve Alwinator/asciidoctor-lists#6

@mojavelinux
Copy link
Member

Looking at the existing API closer, now I'm thinking that source_text for a list item and source_title (or source_line) for a heading/block title would be more fitting.

@mojavelinux
Copy link
Member

This has become a duplicate of #4386 (and vice versa).

@mojavelinux mojavelinux modified the milestones: M2, v2.1.x Apr 22, 2023
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

4 participants