Logs for #nikola for 2017-04-28

13:13:19 <ralsina> queso: let me check
13:13:49 <ralsina> queso: should work as-is
13:13:55 <ralsina> queso: just make it generate HTML
13:14:09 <ralsina> of course, YMMV since noone tried that before AFAIK :-)
13:44:47 <queso> ralsina: So I just put the jinja2 snippet in the latex code?  it doesn't seem to work, it gave me an error.
13:45:07 <ralsina> queso: no, let me get the docs for you
13:45:33 <ralsina> queso: this is probably what you want: https://getnikola.com/handbook.html#template-based-shortcodes
13:46:23 <ralsina> queso: that "no" is a bit hasty, it turns out you CAN put the template in there, but if you are going to use this more than once you should use a separate template file :-)
13:47:31 <queso> I wasn't very clear.  I added the audio.tmpl file to shortcodes/ and then in my post.tex file I put {{% audio src=http://example.com/my-track.mp3 %}}
13:48:13 <queso> When I build the site, it fails because that's not valid latex.
13:49:04 <queso> Maybe I'm misunderstanding how this is supposed to be used.
13:51:00 <ralsina> hmmm
13:51:16 <ralsina> I see, the problem is that we have a conflict with tex syntax there
13:51:28 <ralsina> in most markups, {{% %}} means nothing :-P
13:52:07 <ralsina> queso: if you can finda proper start-end marker that TeX will ignore, then we can make it configurable, I guess
13:57:14 <queso> Am I the only one using nikola with latex? :P
13:58:02 <ralsina> queso: probably!
13:58:21 <ralsina> queso: I did not know you could, really.
13:58:33 <ralsina> or maybe I knew at some point and forgot :-)
13:58:54 <ralsina> Ahhhh via pandoc, not real LaTeX!
13:59:22 <queso> Yup, that's how.
14:03:18 <queso> Boy, I think I really got this wrong.
14:03:31 <queso> That shortcode is for use in templates, not posts.  Right?  I was trying to use it in posts.
14:03:46 <ralsina> No, they are meant for posts
14:04:33 <ralsina> You were using it perfectly right, the problem is that shortcodes in the middle of LaTeX make LaTeX mad.
14:05:22 <queso> Hmm, if I use it in a RST file, it doesn't seem to work.
14:05:44 <ralsina> rst has a problem with URLs
14:05:53 <ralsina> it will convert any naked URL into a link
14:06:02 <ralsina> you can work around it by escaping a bunch of stuff
14:06:34 <ralsina> I really think I need to reimplement a chunk of shortcodes to make it more robust
14:06:35 <queso> The jinja code itself is displaying in the rendered HTML.
14:06:45 <ralsina> it shouldn't do that
14:06:55 <ralsina> is your theme jinja based?
14:07:18 <ralsina> it will use the template engine your theme is using, so if the theme is mako-based jinja templates will not do much
14:07:21 <queso> Oops, no, it's mako, so that's probably why.
14:07:25 <ralsina> :-)
14:07:43 <queso> I can convert it to mako.
14:10:07 <queso> Incidentally, I have been curious: Why not use file extentions that clarify what type of template a file is?  e.g., audio.jinja2 instead of audio.tmpl?  Then you wouldn't have to declare the engine anywhere and an audio.jinja2 and audio.mako version can coexist peacefully.
14:10:40 <queso> Anyway, thanks for your help. :) I'll turn this shortcode into mako and use something besides latex for listing the audio files, that won't be a problem.
14:17:28 <queso> ralsina: Actually, one more question.  Do you know of a way to tell pandoc (or nikola's processing of something through pandoc) to render something as pure html?  The audio tag is really simple, if I could just type the HTML in the LaTeX doc, that'd be pretty easy to do.
14:18:45 <ChrisWarrick> queso: Re templates: Historical reasons. We have .tmpl hard-coded, and it’d be a lot of effort to change that
14:19:12 <queso> Got it, it does seem like that'd be a hard one to change.
14:21:40 <ralsina> queso: in rst you can use .. raw:: , in markdown you can just put the HTML in, in LaTeX I have no idea, cause I know no LaTeX
14:23:29 <ChrisWarrick> That’d be a pandoc-specific thing, not a LaTeX thing even
14:23:40 <queso> Good point.  Thanks guys, I'll ask in #pandoc
14:24:43 <ChrisWarrick> That said, I wouldn’t really recommend writing LaTeX on a Nikola blog, because pandoc is pretty dumb with TeX (and uncustomizable), and TeX is written with paper in mind
14:37:47 <queso> Hmm.
14:38:11 <queso> ChrisWarrick: How is it any more dumb than RST or Markdown?
14:38:34 <ChrisWarrick> queso: what are you writing?
14:39:43 <queso> The idea is that I'm writing stuff in LaTeX already, papers and speeches and various notes.  I want to start putting some of these in a blog.  Instead of reformatting it all in RST, I figured using pandoc would make this pretty easy.
14:40:06 <queso> Lists work, headers work, even footnotes work.
14:40:22 <queso> I'm trying to think of anything that I might need that *wouldn't* work.
14:40:23 <ChrisWarrick> queso: Custom environments often don’t. Fancier stuff might not.
14:40:34 <queso> Right, they won't work.
14:40:51 <queso> I will have to "dumb it down" when I copy it over.
14:41:50 <queso> But what can Markdown do, for example, that the dumbed-down LaTeX-via-pandoc can't do?
14:42:02 <ChrisWarrick> Nothing
14:42:33 <ChrisWarrick> unless you can’t use raw HTML, also shortcodes might not work in LaTeX (I’m not sure if we support them in pandoc, and it might be a pain to write them)
14:42:45 <ChrisWarrick> queso: A pretty advanced book is full of "0.5em" when converted to HTML by Pandoc, because the original TeX had a \dialog command set to "—\hskip0.5em"
14:43:46 <queso> Shortcodes don't work, and I don't think raw HTML is going to work either.
14:44:26 <queso> Bah, I don't know what to use.
14:44:35 <ChrisWarrick> I’d recommend reStructuredText
14:44:59 <ChrisWarrick> maybe you could even manually convert tex to rest and then fix all glitches
14:45:34 <queso> I hadn't thought of doing that.
14:51:14 <queso> latex \footnote{}'s are so much nicer. :P
14:54:53 <ralsina> ChrisWarrick: the code for shortcodes in pandoc is there, I suspect there are a ton of corner cases since pandoc eats many different things
14:55:31 <ChrisWarrick> ralsina: And our syntax is {{% foo %}} — all special TeX characters
14:55:40 <ralsina> exactly
14:55:49 <ralsina> ChrisWarrick: making the delimiter configurable may be a good idea
14:56:25 <ChrisWarrick> ralsina: the code is already a mess I don’t really understand
14:56:31 <ralsina> Also, I want to change how it's done, so we remove the block, replace it with a uuid, then re-replace the uuid with the output of the block
14:57:01 <ralsina> that would fix the whole mess of compilers munging the shortcode before we process it
14:57:40 <queso> I have to work on some other things now.  Thanks for your help, guys.  I'll consider using RST instead of LaTeX for this.
14:57:42 <ChrisWarrick> true, true
14:59:04 <ChrisWarrick> In TeX, you’d need \{\{\% foo \%\}\}, which isn’t *that* bad (things could get interesting with ^ or \)
15:27:22 <ralsina> grmbl, shortcodes.py is complicated
15:27:30 <ralsina> I hate complicated
15:32:08 <SteveDrees> "As simple as possible, none simpler." - Einstein
15:32:43 <ralsina> I am about to do a preliminary branch to un-brainify shortcodes
15:33:00 <ralsina> Because honestly, that code looks like fucking Java
15:34:13 <ChrisWarrick> ralsina: we both know who wrote that
15:34:44 <ralsina> hahaha
15:35:39 <ChrisWarrick> ralsina: Making a parser isn’t easy, especially with no extra library (let’s not go there), but my slightly naïver approach was, I think, more readable and Pythonic. https://github.com/getnikola/nikola/commit/43f9acea15dbfe9eacce4c8f60cb41e10e17ebec#diff-9124d5fa33a41d683db65595e584abb5
15:35:52 <ChrisWarrick> https://github.com/getnikola/nikola/pull/2200
15:36:55 <ralsina> I think I can keep the general gist of how this works but just make it readable
15:37:53 <ralsina> Or maybe just use a freaking parsing library
15:38:05 <ralsina> about to just kill it with fire
15:39:05 <ralsina> considering how stupidly simple the "language" is
15:39:54 <ChrisWarrick> we have enough dependencies
15:40:30 <ralsina> ok, back to making this look like python, then
15:40:47 <ChrisWarrick> (but if I was the one calling the shots, blinker could go for something custom)
15:42:22 <ralsina> I'll give it one hour of effort for cleaning up
15:42:45 <ralsina> if it doesn't, then tomorrow I may just use a parser, blinker, spark or whatever
16:26:47 -GitHub[nikola]:#nikola- [nikola] ralsina created shortcodes2 (+2 new commits): https://git.io/v9cfZ
16:26:47 -GitHub[nikola]:#nikola- nikola/shortcodes2 f5d6133 Roberto Alsina: use text constants instead of integers
16:26:47 -GitHub[nikola]:#nikola- nikola/shortcodes2 9118589 Roberto Alsina: Use shortcodes in a more robust manner
16:29:20 -GitHub[nikola]:#nikola- [nikola] ralsina opened pull request #2737: WIP: use shortcodes in a more robust manner (master...shortcodes2) https://git.io/v9cfg
16:29:39 <ChrisWarrick> ralsina: add ralsina@onapsis.com to your github profile
16:30:06 <ralsina> True that
16:30:08 <ralsina> will do 
16:30:17 -GitHub[nikola]:#nikola- [nikola] ralsina pushed 1 new commit to shortcodes2: https://git.io/v9cfK
16:30:17 -GitHub[nikola]:#nikola- nikola/shortcodes2 359c08e Roberto Alsina: remove pdb call
16:32:02 <ralsina> ChrisWarrick: so, this fixes the problem without touching that whole ... thing
16:32:18 <ralsina> I will still try to do some cosmetic work tho
16:36:05 <ralsina> queso: if you could check whether your shortcodes work better in TeX in https://git.io/v9cfZ that would be nice
16:51:38 -GitHub[nikola]:#nikola- [nikola] ralsina pushed 1 new commit to shortcodes2: https://git.io/v9cTw
16:51:38 -GitHub[nikola]:#nikola- nikola/shortcodes2 c4f8a3f Roberto Alsina: Doh
16:53:42 -GitHub[nikola]:#nikola- [nikola] ralsina pushed 1 new commit to shortcodes2: https://git.io/v9cke
16:53:42 -GitHub[nikola]:#nikola- nikola/shortcodes2 284eb11 Roberto Alsina: Fix codacy-found bug
16:57:08 -GitHub[nikola]:#nikola- [nikola] ralsina pushed 1 new commit to shortcodes2: https://git.io/v9cko
16:57:08 -GitHub[nikola]:#nikola- nikola/shortcodes2 1ccbecf Roberto Alsina: You are right, codacy
16:58:13 <ChrisWarrick> codacy's pretty handy
16:58:21 <ralsina> Yeah, flake8 would have found those
16:58:36 <ralsina> But I am at work, during lunch, so I am kinda distracted :-)
19:16:47 <queso> ralsina: I can try to test that, might not be today though