Writing a Leanpub converter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Writing a Leanpub converter

ysb33r
This post was updated on .
Background: I thought I would rather start a discussion here, as opposed to a drips and drabs conversation via Twitter. The experiment started out trying to use the new AbstractConverter interface that Robert Panzer has been writing for AsciidoctorJ. The end goal is to get a converter done that can go Asciidoctor -> Leanpub.

Callouts:

First up is the case of callouts. Leanpub uses it's own source code highlighting based upon Pygments, and as such andy source needs to be converted to the format Leanpub expects. Leanpub does not support callouts, so a plan has to be made to do this. The final format is up for adjustment, but not the main issue. What is of concern is the extraction of callouts from the source code and storing it.

Dan has pointed me to https://t.co/XMAJCuLppm on a previous occasion, but I can only see a hit on the block processor with transform=listing & style=source in my converter. I don't think at this point the substitution code has been hit yet. From AsciidoctorJ I don't think that specific code can be called and even if we could, it relies on calling the syntax-highlighter engine, which is something we don't want for Leanpub.

It looks like I might have to implement the regexes CalloutExtractRx & CalloutExtractRxt in my converter and then run the removals myself. Comments?

Also under which circumstances will the 'line-comment' attribute be set -> https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/substitutors.rb#L1118
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

ysb33r
This is the solution I came up (with alternative styles) in Leanpub. Any good?


Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

ysb33r
I think the converter is now in a state where people can have at least a play with it as long as you are happy to build you own asciidoctorj SNAPSHOT and the asciidotcor-leanpub-coverter SNAPSHOT.

It's on Github https://github.com/ysb33r/asciidoctor-leanpub-converter
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

mojavelinux
Administrator
Schalk,

This is pretty fantastic already! What's interesting is that it opens up the door to using Leanpub purely as a publishing tool...in other words, a typesetting + delivery tool. The power of Leanpub becomes our power.

What's also great is that you are touching all parts of the AST from Java, driving it towards completion. It's not too much of a stretch now to create a native HTML5 converter. That would likely speed up AsciidoctorJ quite significantly.

I'd actually recommend making the abstract class AbstractMarkdownConverter since that's the base here...or have AbstractMarkdownConverter extend AbstractPlainTextConverter.

The colist styles look good. I like the one with the balloon the best.

Is there a way to convert to the Leanpub Markdown to HTML using an offline tool? Or do you have to import the result into the Leanpub interface?

Great work!!

-Dan


On Sat, May 30, 2015 at 3:16 AM, ysb33r [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I think the converter is now in a state where people can have at least a play with it as long as you are happy to build you own asciidoctorj SNAPSHOT and the asciidotcor-leanpub-coverter SNAPSHOT.

It's on Github https://github.com/ysb33r/asciidoctor-leanpub-converter


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Writing-a-Leanpub-converter-tp3273p3285.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

mojavelinux
Administrator
In reply to this post by ysb33r
It might be nice to add a sample (or example) directory to the project that shows how the converter is used. You explain it in the README, but it takes time to set it up and that's less chance you'll get feedback. Just a build.gradle file + an AsciiDoc document should do.

Cheers,

Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

ysb33r
Thanks for the feedback so far.

The only way I know to generate Leanpub MD, is to either go to the webpage for a book and click the preview, or to invoke it via the REST API. Either way it would end up in the Dropbox share (if that is the way you interact with Leanpub).  I have been thinking of setting up an unpublished example book on Leanpub that can be used purely for testing.

BTW. Do you think this project should be migrated into the asciidoctor organisation on Github?
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

mojavelinux
Administrator
On Sat, Jun 6, 2015 at 6:15 AM, ysb33r [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I have been thinking of setting up an unpublished example book on Leanpub that can be used purely for testing.

Sounds like a good plan.

 

BTW. Do you think this project should be migrated into the asciidoctor organisation on Github?

By all means. I've given you access to transfer when you think it's the right time.

Cheers,

-Dan

--
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

ysb33r
mojavelinux wrote
>
> BTW. Do you think this project should be migrated into the asciidoctor
> organisation on Github?

By all means. I've given you access to transfer when you think it's the
right time.
Done - https://github.com/asciidoctor/asciidoctor-leanpub-converter.
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

ysb33r
In reply to this post by mojavelinux
mojavelinux wrote
It might be nice to add a sample (or example) directory to the project that
shows how the converter is used. You explain it in the README, but it takes
time to set it up and that's less chance you'll get feedback. Just a
build.gradle file + an AsciiDoc document should do.
Done. Example project is at https://github.com/asciidoctor/asciidoctor-leanpub-converter/tree/master/example.

The exmaple published book is at https://leanpub.com/asciidoctortoleanpubsample.

(Unfortunately I have not yet worked out how to give more than one person or entity on Leanpub the ability to publish using multiple keys, so for now I am the only one who can push updates through to Leanpub. Howver I'll ebdeavour to do that as musch as possible if PRs come in)
Reply | Threaded
Open this post in threaded view
|

Re: Writing a Leanpub converter

mojavelinux
Administrator
Great work!

Btw, I used the converter the other day to convert from AsciiDoc to Markdown (for an interface that only accepted Markdown). It worked really nicely! (I plan to submit a few patches to cover cases that aren't yet covered. I'll get to it as soon as I can).

Cheers,

-Dan

On Wed, Jun 10, 2015 at 5:10 PM, ysb33r [via Asciidoctor :: Discussion] <[hidden email]> wrote:
mojavelinux wrote
It might be nice to add a sample (or example) directory to the project that
shows how the converter is used. You explain it in the README, but it takes
time to set it up and that's less chance you'll get feedback. Just a
build.gradle file + an AsciiDoc document should do.
Done. Example project is at https://github.com/asciidoctor/asciidoctor-leanpub-converter/tree/master/example.

The exmaple published book is at https://leanpub.com/asciidoctortoleanpubsample.

(Unfortunately I have not yet worked out how to give more than one person or entity on Leanpub the ability to publish using multiple keys, so for now I am the only one who can push updates through to Leanpub. Howver I'll ebdeavour to do that as musch as possible if PRs come in)


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Writing-a-Leanpub-converter-tp3273p3357.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--