Unfortunately, I'm not going to be at adapt.to :-( wrong side of the pond. So for commonmark, I'm assuming you're referring to this one here:
https://github.com/atlassian/commonmark-java We could embed the JAR into a bundle to provide markdown support and the implementation of the Sling Models and any other services. Let me take a look at it in my copious free time ;-) On Thu, Aug 9, 2018 at 12:05 PM Ioan Eugen Stan <stan.ieu...@gmail.com> wrote: > Hello Daniel, > > I'm very happy to hear you have a use case for it and I hope we can get it > included soon. > > Are you coming to Adapt.to? We might do some work there. > > I'm swamped with other work and can't work on this until then. If you need > it sooner, I can't help you much. > > Regarding markdown support, I failed to convince commonmark developer to > merge my osgi PR's. Maybe you can push a bit and make it happen. If not we > could try to push for flexmark. The developer might be more open to > contributions. This is for longer term. > > Short term you can use the versions I published. > > I saw another discussion about sling and markdown and I saw nice features > being eiscussed (copy front matter properties to jcr properties, caching, > etc) . > > https://github.com/vsch/flexmark-java > > > *De la:* dk...@apache.org > *Trimis:* 9 august 2018 17:59 > *Către:* ieu...@apache.org > *Cc:* users@sling.apache.org > *Subiect:* Re: [DISCUSSION] markdown support for Sling CMS > > Hey Eugen, > > Now that Sling CMS 0.9.0 is out I was thinking adding markdown support to > Sling CMS would be a great addition (in part because I have a use case for > it for filtered user generated content) > > I've created an issue for it: > > https://issues.apache.org/jira/browse/SLING-7819 > > Do you want to create a PR for integrating this? How can I help? > > Thanks, > Dan > > On Wed, Jun 20, 2018 at 10:16 PM Daniel Klco <dk...@apache.org> wrote: > >> >> >> On Sun, Jun 17, 2018, 9:26 PM Eugen Stan <ieu...@apache.org> wrote: >> >>> Hello Daniel and all, >>> >>> I've been working to deliver a piece of functionality that leverages >>> Markdown support and I think it can be a great addition for managing >>> content inside a Sling, more specifically Sling CMS. >>> >>> My work is by no means ready to be released into the open but I would >>> like to share some ideas and get some feedback. I think it could make a >>> great adition to Sling CMS. >>> >>> I've started from commonsmark-java [1] and I have made some PR's to add >>> proper osgi support and Karaf features. Until they are upstreamed, I've >>> published them to my public repository on bintray so you can test it out >>> [2]. >>> >>> I'm currenlty using this functionality to manage terms of use and >>> privacy policy files for our web platform. We have a requirement that >>> they need to be translated and I believe that a text based format has >>> many advantages in this situation than an office document. Most of them >>> are related to the that: >>> >>> - content can be easily version controlled >>> >>> - content can be transformed easily into multiple output formats: html, >>> text, pdf >>> >>> - content is easy to view/edit >>> >>> - rich text editors exist for markdown that can be added >>> >>> >>> The way I am using it in my application is to register a Sling Model >>> that allows me to convert from Markdown content to html on the fly >>> (caching can be added). >> >> >>> I've also defined a script "page/markdown" via sling:resourceType so I >>> can leverage that functionality. My implementation is based on fling >>> sample and uses thymeleaf. >>> >>> Bellow are some code snippets that I use. My implementation needs to >>> handle content into multiple languages and we use a fallback mechanism: >>> If requested language is not available, then we fallback to the default >>> version - which is English version for most cases. >>> >>> ---- >>> >>> @Model(adaptables = {Resource.class, SlingHttpServletRequest.class}) >>> @FieldDefaults(level = AccessLevel.PROTECTED) >>> public class Page { >>> >>> @SlingObject Resource resource; >>> >>> @SlingObject(injectionStrategy = OPTIONAL) >>> SlingHttpServletRequest request; >>> >>> @OSGiService HtmlRenderer htmlRenderer; >>> @OSGiService Parser parser; >>> >>> List<PageTranslation> translations; >>> >>> PageTranslation requestedTranslation; >>> >>> @PostConstruct >>> protected void resolveContent() { >>> Locale lang = requestedLanguage(); >>> translations = getPageTranslations(); >>> >>> log.warn("Parsing translation for resources {}", translations); >>> try { >>> requestedTranslation = findRequestedTranslationOrUseDefault(); >>> } catch (Exception e) { >>> log.warn("Exception getting content ", e); >>> } >>> } >>> >>> private List<PageTranslation> getPageTranslations() { >>> List<PageTranslation> translations = new ArrayList<>(); >>> >>> resource >>> .getChild("lang") >>> .getChildren() >>> .forEach( >>> resource1 -> { >>> PageTranslation translation = >>> resource1.adaptTo(PageTranslation.class); >>> if (translation != null) { >>> translations.add(translation); >>> } >>> }); >>> return translations; >>> } >>> >>> public String getTitle() { >>> return requestedTranslation.getTitle(); >>> } >>> >>> public String getLanguage() { >>> return requestedTranslation.getLanguage(); >>> } >>> >>> public String getContent() { >>> String content = requestedTranslation.getContent(); >>> Node doc = parser.parse(content); >>> return htmlRenderer.render(doc); >>> } >>> >>> ---- >>> >>> I'm hoping this can be added to Sling CMS, pending the markdown changes >>> are upstreamed. >>> >>> I believe text based formats are cool and they solve some problems in an >>> interesting way. >>> >> >> I've used markdown a fair bit and agree for text heavy use cases. >> >> >>> What do you think? Daniel, would you help me shape this so it can be >>> included in Sling CMS ? >> >> >> Totally. It'd seem like we'd need to include a markdown editor, script >> and model to render the markdown content. That way we could show a HTML >> editor and a markdown editor which might be nice from anyone coming from a >> markdown too such as Jekyll. >> >> Not related: I haven't seen a Sling CMS feature >>> in Sling Karaf features. I would like to add one in the near future. >>> >> >> That'd be great! >> >> >>> >>> Other notes: I've targeted asciidoc via asciidoctor but there are issues >>> with running asciidoctorj in osgi. >>> >>> Regards, >>> >>> Eugen >>> >>> [1] https://github.com/atlassian/commonmark-java/pulls >>> >>> [2] https://bintray.com/netdava/maven/commonmark-java >>> >>>