RobertDober
Earmark is a pure-Elixir Markdown converter.
It is intended to be used as a library (just call Earmark.as_html), but can also be used as a command-line tool (run mix escript.build first).
Output generation is pluggable.
- Table Of Content
- Options
- Contributing
- Author
Trending in Announcing
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Hello,
I’m sharing my plugin here in forum after some time so it has time to mature and proof yourself.
I use Claude Code daily on a pr...
New
Aloha gang,
There’s a new class of AI model out from TypeSafe. Jev is their flagship model. You can learn about it here:
...
New
I’ve recently created a small library phoenix_vite integrating the vite build tooling with phoenix.
It
provides an igniter.installer t...
New
I needed something like premailer for rails, and after searching, I decided to make an easy-to-use library to handle inline styles and co...
New
If you’ve ever had to debug a BEAM node you know it can be a painful process. Parsing raw data, or dealing with clutter often gets in the...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
AI tools and services seem to be the new JS framework - with new ones popping up every 5 minutes - hence it might be worth posting one of...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #performance











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
stefanchrobot
Thanks! I was using
Earmark.parseto convert MD to plaintext, but theEarmark.as_astis a much more convenient and simpler API to do the same job.RobertDober
please be aware that Earmark.parse is private now
RobertDober
BTW
1.4.0 2019/09/05
145 Expose AST for output manipulation
238 Pure Links are default now
256 Align needed Elixir Version with ex_doc (>= 1.7)
259 Deprecated option
sanitizeremoved261 Deprecated Plugins removed
265 Make deprecated
Earmark.parse/2privateedisonywh
Wow this is great news, thanks for the update here, AST is going to be incredibly useful!
MarioFlach
I’m using Earmark in my project and I’m planning to implement a few custom markups. For example, auto-link specific characters (
@mentions,#issues, etc.) and support emojis. See almightycouch/gitgud#44.The plugin mechanism as been deprecated in 1.4 and working with the AST should work just fine for implementing custom markups. I see that #27 should provide a way to render the AST as HTML.
When writing custom markups, say
@mentions for example. Should I walk the entire AST searching for a@character in each tag (third element in tuple), ignorecodeelements and build-up the new AST from there?Will a future version of Earmark provide a generic way for this kind of things? I think that most custom markups will need the same mechanism for traversing the AST and skipping content in inline code and code blocks.
Also, if I want to replace a markup with my own implementation, for example by supporting syntax highlighting in code blocks. Should I simply replace each
preAST element with my own element?RobertDober
I am really happy that folks are starting to use the AST.
I would
walkthe AST, I am planning to release such anAstWalkerin a future version, right now I am busy with exposing anAstToHtmlTransformerv1.4.1 ETA middle of this week (as you spotted correctly), but I am hunting jobs right now, so that is not sure yet.Walking the AST yourself should not be a very difficult task, have a look at things like
Macro.prewalkor look at my Traverse lib to get some ideas.Be careful if you want to use the to be released transformer though, if you change the AST’s type it will break, please remember that we are still in experimentation mode.
Summary:
yes #277 will allow you to just change the AST and get your HTML for free iff you do not change the AST’s type
Walking the AST will eventually be facilitated by tools in Earmark or maybe an associated lib, let us not forget that every project using
ex_docwill pull in all of Earmark’s code, so tools shall probably go elsewhere.Yes absolutely change e.g.
{"pre", [], [whatever]}to{"post", atts, whateverelse}just watch out for the correct type.Please keep me updated if you have any problem or question, either here or open a ticket in Earmark.
The more feedback I get, the faster the AST API will converge.
MarioFlach
Sure, this could be implemented in a separated package. Maybe a module such as
AstWalkerwill suffice to cover most cases.I was wondering if the current implementation was working with the AST internally when rendering HTML. Are
Earmark.Optionsreflected in the AST or are they only applied to the rendered HTML?In the meanwhile, can i use
Floki.raw_html/2to render the AST?RobertDober
The internal implementation does not work with the AST yet, but it is a clear goal, and also the reason why the Transformer will stay inside Earmark, as it will be used for
as_htmleventually.There are some subtle differences to Floki, which was the inspiration for the AST, it would be great if the use of Floki.raw_html/2 would work. Please let me know.
One thing I am almost sure would break Floki are comments, as Floki has a different shape for comment nodes, I did not see a reason to not have a more uniform type, so instead of
{:comment, ...}Earmark produces{:comment, [], ...}I apologize but I am too stupid to quote your questions in my answer
RobertDober
And finally, concerning the
Options.Most options are needed for the AST rendering, e.g.
pure_links:however all options concerning the inline rendering are ignored, e.g.smartypants:, and yes the Transformer will take those into account.I guess I can be more precise in the doc in the next version (or I get I nice PR maybe
)
MarioFlach
Will give it a try asap.
Just select the text you want to quote in the comment you want and click the “Quote” popover link.