Prisijungti

Markdown embed extension

TechtronicMindaugas N.
  • 20 Grd '14

Sava bloga sugeneruoti naudoju Pelican ir Markdown, bet problema tame, kad markdown nepalaiko embedding objektus kaip youtubes videos.

Palaiko: Youtube, Vimeo, ShowTerm, Google maps, SoundCloud, Gist, Pdf, Audio ir Video.

http://ix.io/4zS/py

  • 20 Grd '14

Kad jau naudojiesi Python web framework'ais, vėlgi siūlau savo mėgstamą web2py
Jie turi (“out of the box”) markmin, kuris iš tikrųjų yra paturbintas markdown, su embed funkcija ir tt. Visa jų mokomoji medžiaga parašyta su markmin.

Čia trumpai, ką jis moka:
http://web2py.com/books/default/chapter ... min_syntax

Išeities kodas guli čia:
http://web2py.com/examples/static/epydoc/

Pažiūrėk, gal ką sau pritaikysi, arba pasiūlik savo kodą web2py bendruomenei

TechtronicMindaugas N.
  • 20 Grd '14

As mielai keisciau i ka nors rimtesnio, bet man sunkiai sekasi su python, nelabai domina tokia kalba. Pelican man leidzia parasyti keleta jinja2 templates ir automatiskai sugeneruoja is ju static pages bei uploadina ten kur reikia. Man tereikia rasyti emacs'e markdown failiukus kad postinciau i bloga, o tai paprasta ir patogu.

Vienintele problema buvo pats markdown. As planuoju ka nors panasaus i GitWeb generuoti, tai ateiti ziuresiu i rimtesnius frameworkus.

  • 20 Vas '15

Nusprendžiau prisidėt ir aš

Perrašiau Techtronic modulį naudojimui su python-markdown2. Žmonės šneka, kad jis truputi greitesnis bei griežčiau atkartoja John Gruber filosofiją

Mano darbelis guli čia: http://ix.io/grZ/py

Testuojant štai tokia duomenų imtis:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import MediaNeedles as md

text = '''
## Test Samples

https://www.youtube.com/watch?v=Mf2wAEYtrlo
https://vimeo.com/98182203
http://video.webmfiles.org/elephants-dream.webm
http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/Samples/AFsp/M1F1-int24-AFsp.wav
https://soundcloud.com/dj-tj-hampton/vivrant-thing-qtip
http://showterm.io/7b5f8d42ba021511e627e#stop
https://gist.github.com/Checksum/e3e8f052c378f8a0a3a9
https://goo.gl/maps/4v3oV
http://pandas.pydata.org/pandas-docs/dev/pandas.pdf
\n\n*No more samples*
'''

head = '''<!DOCTYPE html><html lang="en-GB"><head><meta charset="utf-8"></head><body>'''
tail = '''</body></html>'''
out = head + md.markdown(text) + tail

print(out)

Virsta į štai tokį html:

<!DOCTYPE html><html lang="en-GB"><head><meta charset="utf-8"></head><body><h2>Test Samples</h2>

<iframe allowfullscreen="yes" frameborder="0" height="450" sandbox="allow-same-origin allow-scripts allow-popups" src="http://www.youtube.com/embed/Mf2wAEYtrlo?html5=1&amp;autohide=1&amp;autoplay=0&amp;cc_load_policy=0&amp;color=red&amp;controls=2&amp;disablekb=0&amp;fs=1&amp;hl=us&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=1&amp;theme=dark" width="100%"><p>Your browser does not support <code>iframe</code> element.</p></iframe>

<iframe allowfullscreen="yes" frameborder="0" height="450" sandbox="allow-same-origin allow-scripts allow-popups" src="http://player.vimeo.com/video/98182203?api=1" width="100%"><p>Your browser does not support <code>iframe</code> element.</p></iframe>

<p><video controls="" height="450" preload="auto" src="http://video.webmfiles.org/elephants-dream.webm" type="video/webm" width="100%"><span>Your browser does not support <code>video</code> element. Click <a href="http://video.webmfiles.org/elephants-dream.webm">here</a> to download this file.</span></video>
<audio controls="" preload="auto" src="http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/Samples/AFsp/M1F1-int24-AFsp.wav" type="audio/wav" width="100%"><span>Your browser does not support <code>audio</code> element. Click <a href="http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/Samples/AFsp/M1F1-int24-AFsp.wav">here</a> to download this file.</span></audio></p>

<iframe allowfullscreen="yes" frameborder="0" height="166" sandbox="allow-same-origin allow-scripts allow-popups" src="http://w.soundcloud.com/player/?url=http://soundcloud.com/dj-tj-hampton/vivrant-thing-qtip?auto_play=false&amp;buying=false&amp;liking=false&amp;download=false&amp;sharing=false&amp;show_artwork=true&amp;show_comments=false&amp;show_playcount=false&amp;show_user=false&amp;color=0065D0" width="100%"><p>Your browser does not support <code>iframe</code> element.</p></iframe>

<iframe allowfullscreen="yes" frameborder="0" height="250" sandbox="allow-same-origin allow-scripts allow-popups" src="http://showterm.io/7b5f8d42ba021511e627e" width="100%"><p>Your browser does not support <code>iframe</code> element.</p></iframe>

<script src="https://gist.github.com/Checksum/e3e8f052c378f8a0a3a9.js" type="text/javascript"></script>

<iframe allowfullscreen="yes" frameborder="0" height="450" sandbox="allow-same-origin allow-scripts allow-popups" src="https://www.google.com/maps/embed/v1/view?key=&amp;center=55.1735998,23.8948016&amp;zoom=7" width="100%"><p>Your browser does not support <code>iframe</code> element.</p></iframe>

<p><object data="http://pandas.pydata.org/pandas-docs/dev/pandas.pdf" height="500" type="application/pdf" width="100%"><span>It appears you don't have a PDF plugin in this browser. Click <a href="http://pandas.pydata.org/pandas-docs/dev/pandas.pdf">here</a> to download this file.</span></object></p>

<p><em>No more samples</em></p>
</body></html>

Sėkmės!

TechtronicMindaugas N.
  • 20 Vas '15

@Ghost, nuostabu, gal imanoma merge i viena ? Bet kad pamegintu rasti ar yra markdown ir jeigu nera naudotu markdown2 ?

As jau esu darases ir daugiau embeds, tai butu kiek paprasciau juos update.

  • 20 Vas '15

Žinoma, kodėl gi ne

Atsakyti