public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Create ePub from Markdown with Pandoc API
@ 2014-11-19  5:26 Seri
       [not found] ` <26b25b1e-7f3e-4738-aafc-a627c37b6510-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Seri @ 2014-11-19  5:26 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 1458 bytes --]

I could create an EPUB e-book from the pandoc CLI like this:

    pandoc -o book-cli.epub book.md


But I am rather interested in using the pandoc API, so I tried re-creating 
the same book like this:

    import Text.Pandoc
>     import qualified Data.ByteString.Lazy.Char8 as B


>     main = readFile "book.md" >>= writeEPUB def . readMarkdown def >>= 
> B.writeFile "book.epub"


While `book-cli.epub` is completely fine, `book.epub` contains only the 
headings and no contents. I tried on several EPUB readers and noticed the 
same behavior. Here is the full content of `book.md`:

    This is my book!
>     # Chapter One
>     Chapter one is over.
>     # Chapter Two
>     Chapter two has just begun.


I am guessing that I have to supply some particular options instead of 
using `def`, but I couldn't figure out exactly what needs to be done from 
pandoc's API documentation.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/26b25b1e-7f3e-4738-aafc-a627c37b6510%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 2839 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found] ` <26b25b1e-7f3e-4738-aafc-a627c37b6510-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2014-11-20  7:09   ` Seri
       [not found]     ` <c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Seri @ 2014-11-20  7:09 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 964 bytes --]

I managed to make a little progress. I can confirm that `readMarkdown def` 
works just fine since the resulting Pandoc does contain everything. 
However, when it is fed into `writeEPUB def`, the content (the `Para` 
elements in Pandoc format) is somehow lost. The resulting EPUB looks like 
this:

Chapter One 

Chapter Two


I have tried different `WriterOptions` but still did not succeed.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1787 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]     ` <c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2014-11-20 17:27       ` John MacFarlane
       [not found]         ` <20141120172705.GB91479-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2014-11-20 17:27 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

You need to set writerTemplate in WriterOptions.
See Text.Pandoc.Templates for a function that will get the
default epub template.

+++ Seri [Nov 19 14 23:09 ]:
>I managed to make a little progress. I can confirm that `readMarkdown def`
>works just fine since the resulting Pandoc does contain everything.
>However, when it is fed into `writeEPUB def`, the content (the `Para`
>elements in Pandoc format) is somehow lost. The resulting EPUB looks like
>this:
>
>Chapter One
>
>Chapter Two
>
>
>I have tried different `WriterOptions` but still did not succeed.
>
>-- 
>You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]         ` <20141120172705.GB91479-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2014-11-21  7:04           ` Seri
       [not found]             ` <a2ba29af-cbb1-4cf2-aca0-88f94ddd3888-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Seri @ 2014-11-21  7:04 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 2331 bytes --]

Thanks a lot! I got that issue fixed now. But I'm getting another problem 
regarding unicode characters. With the following markdown file:

# Chapter one

 

Chúng ta


The resulting epub won't render the unicode character properly. Once again, 
no problem whatsoever from the command line. And I'm using the template 
returned from `getDefaultTemplate Nothing "epub"`.


Vào 00:27:20 UTC+7 Thứ sáu, ngày 21 tháng mười một năm 2014, John 
MacFarlane đã viết:

> You need to set writerTemplate in WriterOptions. 
> See Text.Pandoc.Templates for a function that will get the 
> default epub template. 
>
> +++ Seri [Nov 19 14 23:09 ]: 
> >I managed to make a little progress. I can confirm that `readMarkdown 
> def` 
> >works just fine since the resulting Pandoc does contain everything. 
> >However, when it is fed into `writeEPUB def`, the content (the `Para` 
> >elements in Pandoc format) is somehow lost. The resulting EPUB looks like 
> >this: 
> > 
> >Chapter One 
> > 
> >Chapter Two 
> > 
> > 
> >I have tried different `WriterOptions` but still did not succeed. 
> > 
> >-- 
> >You received this message because you are subscribed to the Google Groups 
> "pandoc-discuss" group. 
> >To unsubscribe from this group and stop receiving emails from it, send an 
> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> <javascript:>. 
> >To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0%40googlegroups.com. 
>
> >For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a2ba29af-cbb1-4cf2-aca0-88f94ddd3888%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 4506 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]             ` <a2ba29af-cbb1-4cf2-aca0-88f94ddd3888-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2014-11-21 18:02               ` John MacFarlane
       [not found]                 ` <20141121180250.GE97029-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2014-11-21 18:02 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

It probably has to do with the way you are getting the input.
How are you generating the Pandoc structure that you are passing
to writeEPUB?

Try printing that structure before passing it to writeEPUB,
so you can see if the unicode looks right.

+++ Seri [Nov 20 14 23:04 ]:
>Thanks a lot! I got that issue fixed now. But I'm getting another problem
>regarding unicode characters. With the following markdown file:
>
># Chapter one
>
>
>
>Chúng ta
>
>
>The resulting epub won't render the unicode character properly. Once again,
>no problem whatsoever from the command line. And I'm using the template
>returned from `getDefaultTemplate Nothing "epub"`.
>
>
>Vào 00:27:20 UTC+7 Thứ sáu, ngày 21 tháng mười một năm 2014, John
>MacFarlane đã viết:
>
>> You need to set writerTemplate in WriterOptions.
>> See Text.Pandoc.Templates for a function that will get the
>> default epub template.
>>
>> +++ Seri [Nov 19 14 23:09 ]:
>> >I managed to make a little progress. I can confirm that `readMarkdown
>> def`
>> >works just fine since the resulting Pandoc does contain everything.
>> >However, when it is fed into `writeEPUB def`, the content (the `Para`
>> >elements in Pandoc format) is somehow lost. The resulting EPUB looks like
>> >this:
>> >
>> >Chapter One
>> >
>> >Chapter Two
>> >
>> >
>> >I have tried different `WriterOptions` but still did not succeed.
>> >
>> >--
>> >You received this message because you are subscribed to the Google Groups
>> "pandoc-discuss" group.
>> >To unsubscribe from this group and stop receiving emails from it, send an
>> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>.
>> >To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>> <javascript:>.
>> >To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pandoc-discuss/c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0%40googlegroups.com.
>>
>> >For more options, visit https://groups.google.com/d/optout.
>>
>>
>
>-- 
>You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/a2ba29af-cbb1-4cf2-aca0-88f94ddd3888%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20141121180250.GE97029%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]                 ` <20141121180250.GE97029-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2014-11-22  6:21                   ` Seri
       [not found]                     ` <4c8b83d5-fee2-4e47-9bbb-5b65ffd5c201-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Seri @ 2014-11-22  6:21 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 4029 bytes --]

Yes, I did just that to isolate the problem and it seems to be in the 
writing part. Here is the String version of the Pandoc structure:

Pandoc (Meta {unMeta = fromList []}) [Header 1 ("chapter-one",[],[]) [Str 
> "Chapter",Space,Str "one"],Para [Str "Ch\195\186ng",Space,Str "ta"]]
>

\195\186 is the correct UTF-8 code for my character. I get the Pandoc like 
this:

getInput = B.readFile "note.markdown" >>= return . readMarkdown def . 
> B.unpack
>

Vào 01:03:04 UTC+7 Thứ bảy, ngày 22 tháng mười một năm 2014, John 
MacFarlane đã viết:
>
> It probably has to do with the way you are getting the input. 
> How are you generating the Pandoc structure that you are passing 
> to writeEPUB? 
>
> Try printing that structure before passing it to writeEPUB, 
> so you can see if the unicode looks right. 
>
> +++ Seri [Nov 20 14 23:04 ]: 
> >Thanks a lot! I got that issue fixed now. But I'm getting another problem 
> >regarding unicode characters. With the following markdown file: 
> > 
> ># Chapter one 
> > 
> > 
> > 
> >Chúng ta 
> > 
> > 
> >The resulting epub won't render the unicode character properly. Once 
> again, 
> >no problem whatsoever from the command line. And I'm using the template 
> >returned from `getDefaultTemplate Nothing "epub"`. 
> > 
> > 
> >Vào 00:27:20 UTC+7 Thứ sáu, ngày 21 tháng mười một năm 2014, John 
> >MacFarlane đã viết: 
> > 
> >> You need to set writerTemplate in WriterOptions. 
> >> See Text.Pandoc.Templates for a function that will get the 
> >> default epub template. 
> >> 
> >> +++ Seri [Nov 19 14 23:09 ]: 
> >> >I managed to make a little progress. I can confirm that `readMarkdown 
> >> def` 
> >> >works just fine since the resulting Pandoc does contain everything. 
> >> >However, when it is fed into `writeEPUB def`, the content (the `Para` 
> >> >elements in Pandoc format) is somehow lost. The resulting EPUB looks 
> like 
> >> >this: 
> >> > 
> >> >Chapter One 
> >> > 
> >> >Chapter Two 
> >> > 
> >> > 
> >> >I have tried different `WriterOptions` but still did not succeed. 
> >> > 
> >> >-- 
> >> >You received this message because you are subscribed to the Google 
> Groups 
> >> "pandoc-discuss" group. 
> >> >To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >> >To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> >> <javascript:>. 
> >> >To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/pandoc-discuss/c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0%40googlegroups.com. 
>
> >> 
> >> >For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> > 
> >-- 
> >You received this message because you are subscribed to the Google Groups 
> "pandoc-discuss" group. 
> >To unsubscribe from this group and stop receiving emails from it, send an 
> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> >To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> <javascript:>. 
> >To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/a2ba29af-cbb1-4cf2-aca0-88f94ddd3888%40googlegroups.com. 
>
> >For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4c8b83d5-fee2-4e47-9bbb-5b65ffd5c201%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 6907 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]                     ` <4c8b83d5-fee2-4e47-9bbb-5b65ffd5c201-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2014-11-22  6:46                       ` John MacFarlane
       [not found]                         ` <20141122064618.GB3283-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2014-11-22  6:46 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ Seri [Nov 21 14 22:21 ]:
>Yes, I did just that to isolate the problem and it seems to be in the
>writing part. Here is the String version of the Pandoc structure:
>
>Pandoc (Meta {unMeta = fromList []}) [Header 1 ("chapter-one",[],[]) [Str
>> "Chapter",Space,Str "one"],Para [Str "Ch\195\186ng",Space,Str "ta"]]
>>
>
>\195\186 is the correct UTF-8 code for my character.

Then this isn't correct.  The problem is in the input.

Haskell strings are lists of unicode code points, not UTF-8 octets.  So
Chúng should be Str "Ch\250ng".

Sounds as if you aren't decoding the UTF-8 before passing to pandoc.
You can use functions in Text.Pandoc.UTF8 for this.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20141122064618.GB3283%40localhost.hsd1.ca.comcast.net.
For more options, visit https://groups.google.com/d/optout.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Create ePub from Markdown with Pandoc API
       [not found]                         ` <20141122064618.GB3283-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
@ 2014-11-22  7:40                           ` Seri
  0 siblings, 0 replies; 8+ messages in thread
From: Seri @ 2014-11-22  7:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


[-- Attachment #1.1: Type: text/plain, Size: 614 bytes --]

Yes, Text.Pandoc.UTF8 fixed that. Thanks!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d29b6f94-f3f5-45b9-bffa-45ede711ac8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1026 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-11-22  7:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-19  5:26 Create ePub from Markdown with Pandoc API Seri
     [not found] ` <26b25b1e-7f3e-4738-aafc-a627c37b6510-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-11-20  7:09   ` Seri
     [not found]     ` <c5f0ab8a-3fd6-4b03-9bdb-4b51b6c376c0-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-11-20 17:27       ` John MacFarlane
     [not found]         ` <20141120172705.GB91479-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2014-11-21  7:04           ` Seri
     [not found]             ` <a2ba29af-cbb1-4cf2-aca0-88f94ddd3888-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-11-21 18:02               ` John MacFarlane
     [not found]                 ` <20141121180250.GE97029-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2014-11-22  6:21                   ` Seri
     [not found]                     ` <4c8b83d5-fee2-4e47-9bbb-5b65ffd5c201-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2014-11-22  6:46                       ` John MacFarlane
     [not found]                         ` <20141122064618.GB3283-bi+AKbBUZKbivNSvqvJHCtPlBySK3R6THiGdP5j34PU@public.gmane.org>
2014-11-22  7:40                           ` Seri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).