including HTML in my post

34 views
Skip to first unread message

Dave

unread,
Aug 26, 2016, 5:07:27 PM8/26/16
to nikola-discuss
I know this isn't a strictly nikola question, but I cannot seem to find anything on it. By my googling, I am the only person ever to want to do this.

I want to add some custom HTML to a rest post
i.e.

<picture>
   <source srcset="smaller.jpg" media="(max-width: 768px)">
   <source srcset="default.jpg">
   <img srcset="default.jpg" alt="My default image">
</picture>







As from what I can tell, REST doesn't have a way to specify a picture tag, so I will parse the .rst files, detect images, generate the responsive images and replace with a <picture> tag. But after a couple of hours of searching I have come up with nothing.

I am sure it must be possible,I am sure it is simple and I am sure it is staring me in the face, but I cannot see it :)



Cheers

Dave

unread,
Aug 26, 2016, 5:22:38 PM8/26/16
to nikola-discuss
as always, my very next search has found the answer ffs

.. raw:: html

   
<picture>

       
<source srcset="smaller.jpg" media="(max-width: 768px)">
       
<source srcset="default.jpg">
       
<img srcset="default.jpg" alt="My default image">
   
</picture>




:-)

Roberto Alsina

unread,
Aug 26, 2016, 5:24:37 PM8/26/16
to nikola-discuss

To avoid repeat in yourself too much you may want to look at shortcodes in the Nikola manual, too.


--
You received this message because you are subscribed to the Google Groups "nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

prosrcmedia

unread,
Aug 26, 2016, 6:58:02 PM8/26/16
to nikola-...@googlegroups.com
I did check the handbook, but I guess my skim reading and the content
for raw:


>> raw Passes the content along, mostly used so I can write this damn section and you can see the shortcodes
>> instead of them being munged into shortcode output. I can't show an example because Inception.

didn't catch my eye. Now I know "raw" is what I need, it makes sense,
before - -not so much. I guess I was skimming for the word "html".


:-)




On 26/08/2016 16:24, Roberto Alsina wrote:
> To avoid repeat in yourself too much you may want to look at shortcodes
> in the Nikola manual, too.
>
>
> El vie., ago. 26, 2016 18:22, Dave <prosr...@gmail.com
> <mailto:prosr...@gmail.com>> escribió:
>
> as always, my very next search has found the answer ffs
>
> |
> ..raw::html
> <mailto:nikola-discus...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "nikola-discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nikola-discuss/eq1ZjwN5PNw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> nikola-discus...@googlegroups.com
> <mailto:nikola-discus...@googlegroups.com>.

Roberto Alsina

unread,
Aug 26, 2016, 9:09:05 PM8/26/16
to nikola-...@googlegroups.com

Actually, the raw shortcut is not what I meant. It's late and I am on the phone but I will reply with a decent example tomorrow.


To unsubscribe from this group and stop receiving emails from it, send an email to nikola-discus...@googlegroups.com.

Samat K Jain

unread,
Sep 7, 2016, 7:18:19 PM9/7/16
to nikola-...@googlegroups.com
On 08/26/2016 07:08 PM, Roberto Alsina wrote:
> Actually, the raw shortcut is not what I meant. It's late and I am on
> the phone but I will reply with a decent example tomorrow.

Roberto,

Could you share that example?

Thanks!

--
Samat K Jain • GPG: 0x4A456FBA • Pump.IO: https://identi.ca/samatjain
Web: https://samat.org/ • Twitter: https://twitter.com/SamatJain

This e-mail is: [ ] shareable [x] ask first [ ] private

Roberto Alsina

unread,
Sep 7, 2016, 7:27:12 PM9/7/16
to nikola-...@googlegroups.com
Sorry, totally forgot.

Basically, if you put something like this in shortcodes/picture.tmpl

<picture>
   <source srcset="${args[0]}" media="(max-width: 768px)">
   <source srcset="${args[1]}">
   <img srcset="${args[1]}" alt="${alt}">
</picture>

Then you can do this in any post:

{{% picture small.jpg default.jpg alt="My Image"%}}

And you will get the markup you want.


Dave

unread,
Sep 8, 2016, 5:42:32 PM9/8/16
to nikola-discuss, ral...@kde.org
Very nice, didn't know about that!
Reply all
Reply to author
Forward
0 new messages