{"action":"closed","issue":{"url":"https://api.github.com/repos/chjj/marked/issues/773","repository_url":"https://api.github.com/repos/chjj/marked","labels_url":"https://api.github.com/repos/chjj/marked/issues/773/labels{/name}","comments_url":"https://api.github.com/repos/chjj/marked/issues/773/comments","events_url":"https://api.github.com/repos/chjj/marked/issues/773/events","html_url":"https://github.com/chjj/marked/issues/773","id":167392457,"number":773,"title":"Prevent images from wrapping in paragraph tags","user":{"login":"sn3p","id":935529,"avatar_url":"https://avatars.githubusercontent.com/u/935529?v=3","gravatar_id":"","url":"https://api.github.com/users/sn3p","html_url":"https://github.com/sn3p","followers_url":"https://api.github.com/users/sn3p/followers","following_url":"https://api.github.com/users/sn3p/following{/other_user}","gists_url":"https://api.github.com/users/sn3p/gists{/gist_id}","starred_url":"https://api.github.com/users/sn3p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sn3p/subscriptions","organizations_url":"https://api.github.com/users/sn3p/orgs","repos_url":"https://api.github.com/users/sn3p/repos","events_url":"https://api.github.com/users/sn3p/events{/privacy}","received_events_url":"https://api.github.com/users/sn3p/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-25T15:19:00Z","updated_at":"2016-08-11T14:13:47Z","closed_at":"2016-08-11T14:13:47Z","body":"I'm rendering images inside a `<figure>` element like this:\r\n\r\n```js\r\nvar renderer = new marked.Renderer();\r\n\r\nrenderer.image = function (href, title, alt) {\r\n  var out = '<figure>';\r\n  out += '<img src=\"' + href + '\" alt=\"' + alt + '\">';\r\n  if (title) {\r\n    out += '<figcaption>' + title + '</figcaption>';\r\n  }\r\n  out += '</figure>';\r\n  return out;\r\n};\r\n\r\nmarked.setOptions({\r\n  gfm: true,\r\n  renderer: renderer\r\n});\r\n```\r\n\r\nFigure elements are block level, but markdown wraps the output inside a`<p>`:\r\n\r\n```html\r\n<p><figure><img src=\"http://someimage.png\" alt=\"\">...</figure></p>\r\n```\r\n\r\nBut this is not valid HTML and renders like this: \r\n\r\n```html\r\n<p></p>\r\n<figure><img src=\"http://someimage.png\" alt=\"\">...</figure>\r\n<p></p>\r\n```\r\n\r\nI found out that lexers have a `paragraph` type, but I'm not sure how to set these:\r\n\r\n```js\r\nvar token = marked.lexer('![](http://someimage.png)')\r\n// [{\r\n//   text: \"![](http://someimage.png)\",\r\n//   type: \"paragraph\"\r\n// }]\r\n\r\nmarked.parser(token)\r\n// \"<p><figure><img src=\"http://someimage.png\" alt=\"\"></figure></p>\"\r\n```\r\n\r\n**How to prevent a renderer method getting wrapped in a paragraph element?**"}}
{"actor":{"display_login":"sn3p"}}