Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown parsing of descriptions #206

Closed
nodiscc opened this issue Apr 27, 2015 · 15 comments
Closed

Markdown parsing of descriptions #206

nodiscc opened this issue Apr 27, 2015 · 15 comments
Labels
Milestone

Comments

@nodiscc
Copy link
Member

nodiscc commented Apr 27, 2015

Add an option to render link descriptions from markdown to HTML.
Should be a plugin, blocked by #14, #164

@nodiscc nodiscc added plugin bells and whistles feature labels Apr 27, 2015
@alexisju
Copy link

I have tested the implementation of parsedown from "shinterest" https://github.com/broncowdd/Shinterest. It's basically working but still buggy (ie link parsing like [text](http://link) doesn't work).

I have also tried the zepto.js method. It is supposed working but not easy to use for the user:
http://user23.net/bin/?3fba27786063f200#JdFe9TdWx+2TVMFiFLtTqYAQfpgoXeZzIbn8W75blC4=

I've also tried js client methods but it slow down shaarli to much
https://github.com/p01/mmd.js
https://github.com/dnordstrom/parseMarkdown.js
https://github.com/borgar/textile-js

https://github.com/dtjm/plaintext.js

Finaly, for shaarli, php method remain the best. I've tried to enable it into a template but it seems difficult (due to rainTPL). It need to be implemeted into core shaarli( maybe not as plugin).

Parsedown seems to be a good way:
https://github.com/erusev/parsedown

@alexisju
Copy link

alexisju commented May 1, 2015

Maybe is it possible to to adapt Timo's code from BlogoText ?

https://github.com/timovn/blogotext/blob/master/inc/conv.php

@alexisju
Copy link

alexisju commented May 6, 2015

Implemented into this fork : Knah-Tsaeb@6f4fd91 (works very well : http://effingo.be/test/shaarli-md/?#3gLwbA temporary login:test/test)

@nodiscc nodiscc added this to the 1.1 milestone May 6, 2015
@alexisju
Copy link

alexisju commented May 7, 2015

@nodiscc you tagged this issue as plugin : is it possible to load external includes (ie: parsedown.php) into template? (when i tried i got errors from RainTPL)

@nodiscc
Copy link
Member Author

nodiscc commented May 11, 2015

is it possible to load external includes (ie: parsedown.php)

Ideally it should be, but the plugin system is unfinished work. A markdown plugin would look like

└── tpl
    └── plugins
        └── markdown
            ├── README.md
            ├── markdown.description.html
            ├── markdown.png
            └── php-markdown.php

where all rendering of the description area in the linklist is left to the markdown plugin.

https://github.com/piero-la-lune/Bumpy-Booby uses PHP-Markdown and it works wonderfully. by the way this is a very good bug/issue tracker and you should try it if you need a personal, self-hosted issue tracker

@webdev23
Copy link

Hi everyone. I am the author of the "zepto.js" metod that alexisju linked up:
Retrouver (la syntaxe perdue de) Shaarli:
http://user23.net/links/?08KERw
http://user23.net/bin/?3fba27786063f200#JdFe9TdWx+2TVMFiFLtTqYAQfpgoXeZzIbn8W75blC4=

I just tested this on a fresh install and it work fluently. Here is a more accurate description of what to do for make it work. We can also use jquery, already included (but 3 times bigger):
So by adding, in /tpl/includes.html, line 10:
...script src="../inc/jquery-1.11.2.min.js"></script...

In /tpl/linklist.html:
On line 45, add a variable ID on the div with the class "linkdescription":
{if="$value.description .... div id="ldesc_{$value.linkdate}" class="linkdescription">{$value.description.../div>{/if}

On line 66, this script block:
(retrieve it on the zerobin)

Work directly, like this:*
{pic http://mypic.com/test.jpg pic}
{audio http://mysound.com/yo.mp3 audio}
{1 My big tittle h1 1}
{lt line-trought barré lt}
(..)

I left a shaarli online with the modification http://user23.net/_test/shaarli_dev/ so you can evaluate the performance.
As you can see there is some php errors with plugins (was present at install, not my modification)

I am trying to adapt this as a plugin. I get stucked on something. The loop is not working when i put the script part in the plugin folder.
└── tpl
└── plugins
└── shaardown
├── shaardown.linklist.html

And declare it as a plugin on index.php line 36:
$GLOBALS['config']['PLUGINS'] = array('archiveorg', 'playvideos', 'qrcode', 'readityourself', 'wallabag','shaardown'); // List of enabled plugins

I also tried to create an option.php in the data folder, but same.
I think it should work like this out of the box?
What i missed for make the loop work?
What do you think of the syntax? The real markdown (with a lot of ###) is not simple to filter, that's why i used the {} at this time.
Plugin system is a nice idea but i don't get it now!
Cheers brothers!

alexisju referenced this issue in Knah-Tsaeb/myShaarli May 12, 2015
[fix] enables automatic line breaks
@nodiscc
Copy link
Member Author

nodiscc commented May 12, 2015

Hi @webdev23 the plugin system is currently unfinished and you'd have to extend it before being able to parse descriptions with it. See the commit messages in my new-plugin-sytem branch to get an idea of how it works/is extensible/limited. Someone may be able to help us (I won't have time to finish it soon), but you should really put up a git repository showing the exact changes you applied. For clarity.

I should have said A markdown plugin would look like [...] when parsing descriptions through a plugin is implemented. The plugin system currently only allows adding custom HTML code to <head>, toolbar section and link buttons (date/qr code area). This is also not in master Sorry if I was unclear.

Other than that, I think the markdown syntax is already widely used, known, feature complete and already existing markdown parsers are well tested and spare us most of the work (writing a custom syntax) - that's why I'm interested in a markdown plugin. But a custom plugin that parses descriptions in whatever other markup could be a first step, so thanks for looking into this.

@alexisju
Copy link

alexisju commented Jul 8, 2015

Should we really "wait" a working plugin system rather implement md by default?

Again, the code from Knah-Tsaeb seems clean and could be pushed* into current shaarli. It seems standardised md and reliable (from parsedown.org).

*In fact it cannot be pushed directly because the code is not based on the index.php from this repository, but it can be adapted, as well as the the css to work with this fork.

Commit : Knah-Tsaeb@6f4fd91

You can test md here : http://effingo.be/test/shaarli-md/ (test/test)

@ArthurHoaro
Copy link
Member

Maybe we should rather go for a client side Markdown renderer (JS).

The main advantage is that we don't need to alter data (existing links) when it is enabled/disabled.

@alexisju
Copy link

I tested some in js but it slowdown the rendering of shaarli...

@ArthurHoaro
Copy link
Member

Yeah forget that. We can render it before displaying it, without altering data. Didn't had enough coffee yet. :)

@nodiscc
Copy link
Member Author

nodiscc commented Jul 12, 2015

This should still be off by default;

  • Enabling it for previously saved links would lead to display problems for plain text descriptions that contains characters such as _*[] and html tags.
  • When shaaring a link from the bookmarklet, with some text selected, the selected text should not contain any of these characters, otherwise they will be interpreted and rendered as markdown (whereas on the source page, they are just plain text)

@alexisju
Copy link

I'm not sure to understand what can be the problem. It is very rare to met an article who uses the md syntax by accident. And if it happens, or if _ * or [ ] are in a text, it cannot do something wrong, even using the bookmaklet or doing a copy/paste.

Moreover, in our case md is supposed only to parse description (not tags) and the parsedown classe doesn't interpret html.

But maybe it is more convenient to enable (or not) this functionaly by the plugin system who is comming.

@ArthurHoaro ArthurHoaro modified the milestones: 0.7.0, 1.1.0 Sep 11, 2015
@ArthurHoaro
Copy link
Member

ping #282

@ArthurHoaro
Copy link
Member

Fixed with plugin in #282.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants