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

question: exporting word specific tags #2542

Closed
st32lthx opened this issue Nov 17, 2015 · 14 comments
Closed

question: exporting word specific tags #2542

st32lthx opened this issue Nov 17, 2015 · 14 comments

Comments

@st32lthx
Copy link

Is it possible to export documents with cues for word styles ? For example, let's say in my reference docx file there is a style called cool style. Is there a way to add some cues in the markdown file so that when it is exported it gets the correct styles ? Something like:

file.md

This is a sentence with {special style}(cool-style)

Thanks !

@jgm
Copy link
Owner

jgm commented Nov 17, 2015

+++ Amin Meyghani [Nov 16 15 19:46 ]:

Is it possible to export documents with cues for word styles ?

Currently, no. But in principle it should be possible to
set things up so that <span class="foo">bar</span> gets
rendered with style "Span-foo" (or something like that).
Alternatively there could be a special attribute,
<span data-word-style="foo">.

@st32lthx
Copy link
Author

Awesome ! Any pointers on how to get that work ? Would it be something like this:

file.md -> css, html -> docx ?

Thanks!

@jgm
Copy link
Owner

jgm commented Nov 17, 2015

I can implement it (it would be direct md -> docx). It's just a matter of
figuring out what scheme makes most sense (mapping all
classes on spans to correspondingly named Word styles,
if they are defined, might make most sense).

+++ Amin Meyghani [Nov 16 15 20:13 ]:

Awesome ! Any pointers on how to get that work ? Would it be something
like:

file.md -> css, html -> docx

Thanks!


Reply to this email directly or [1]view it on GitHub.

References

  1. question: exporting word specific tags #2542 (comment)

@mb21
Copy link
Collaborator

mb21 commented Dec 31, 2015

As proposed by massifrg on pandoc-discuss, this issue could be extended to:

  1. cover not only DOCX, but also ODT and ICML
  2. and cover not only Inlines (spans) but also Blocks (divs) (i.e. not only "character styles" but also "paragraph styles")

btw, do the styles really need to be defined in the reference word file or ICML template to trigger the rendering of those spans/divs as styles? Seems like a lot of work parsing those... Maybe a prefix like style- is enough, e.g. <span class="style-foo">bar</span>, or a custom attribute: <span data-style="foo">bar</span>.

@mb21
Copy link
Collaborator

mb21 commented Dec 31, 2015

In LaTeX those divs/spans could be rendered as custom environments/commands. This was actually proposed by @hadley in #168, or do you think the concepts are not analogous enough?

@jgm
Copy link
Owner

jgm commented Dec 31, 2015

+++ Mauro Bieg [Dec 31 15 09:38 ]:

In LaTeX those divs/spans could be rendered as custom
environments/commands. This was actually proposed by [1]@hadley in
[2]#168, or do you think the concepts are not analogous enough?

I want to avoid generating environments and commands that
aren't defined (and similarly for styles in Word and ICML).
If we parse the styles, and thus know what is available,
that may not be a big problem. In LaTeX it's harder,
because commands and environments may be defined in
included packages. The idea of having a special prefix
like style- might be a good one.

@bpj
Copy link

bpj commented Jan 3, 2016

I have written several fairly simple filters, both bespoke and more general, which insert raw latex before and/or after spans or divs based on classes or custom attributes. (An example) Since that, as @jgm said, requires that the inserted commands/environments are or get defined somewhere it is probably better to leave that to filters so that the user is in full control, since they must include the necessary macro definitions at the same time. Too much 'automagic' with such things will be troublesome.

@massifrg
Copy link

massifrg commented Jan 8, 2016

I'm trying to pass the "style-..." classes to ICML with a filter that injects RawInlines into ICML.
Example:

  <span class="style-foo">custom style</span>

becomes (pandoc --filter myfilter.pl -f markdown -t icml)

  <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/foo">
    <Content>custom style</Content>
  </CharacterStyleRange>

I'm not following jgm's rule of not defining styles that are not present in the target document, because it's a custom filter for personal and exploratory purposes (for now).

Anyway that was enough to stumble upon a problem: nested character styles.
What would you get trying to convert this?

  <span class="style-foo">custom <span class="style-bar">style</span></span>

In HTML you can nest a <span> inside another <span>, multiple times.

In ICML you can't nest a <CharacterStyleRange> inside another <CharacterStyleRange>.

That is true for DOCX too, where you can't nest a <w:r> inside another <w:r>.

In ODT you can nest a nest a <text:span> inside another <text:span>, but you won't be able to do it with AOO Writer or LO Writer. You can do it by editing the XML directly, and you obtain what you would expect: the styles merge when they are applied together. Perhaps when you reopen it in LO Writer one of the <text:span> would be considered the character style and the others would be transformed into local modifications.
The question is well summarized in this forum.

Before passing custom styles to target documents, there's a problem of "flattening" the character styles' depth to one level, and there's not a unique (and perhaps neither a good) way to do it.
It's a problem you face even with a simple filter, before you think to add this feature to pandoc.

Anyway I'm trying to write that filter, because my documents are in HTML and passing styles to InDesign is a great feature. I'll let you know. That could be a contribution useful for a more general solution.

@mb21
Copy link
Collaborator

mb21 commented Aug 16, 2016

I guess this issue was resolved through #3070, thanks @jkr :)

@jgm
Copy link
Owner

jgm commented Aug 16, 2016

I think that's right, I'll close this.

@jgm jgm closed this as completed Aug 16, 2016
@monobjorn
Copy link

@massifrg Would you like to share your filter? I would really appreciate it.

@rufuspollock
Copy link

rufuspollock commented May 25, 2018

To clarify:

Also I'm not clear there is any support for docx => ICML export of specific tags atm (or is there)?

@mb21
Copy link
Collaborator

mb21 commented May 25, 2018

I think the issue tracking custom styles for more writer is #2106

@rufuspollock
Copy link

@mb21 so #2663 should really be open or closed in favour of #2106 (not this issue)?

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

No branches or pull requests

7 participants