{"action":"created","issue":{"url":"https://api.github.com/repos/datenstrom/yellow/issues/107","labels_url":"https://api.github.com/repos/datenstrom/yellow/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/datenstrom/yellow/issues/107/comments","events_url":"https://api.github.com/repos/datenstrom/yellow/issues/107/events","html_url":"https://github.com/datenstrom/yellow/issues/107","id":109764893,"number":107,"title":"Markdown formatting with CSS classes","user":{"login":"BsNoSi","id":2784683,"avatar_url":"https://avatars.githubusercontent.com/u/2784683?v=3","gravatar_id":"","url":"https://api.github.com/users/BsNoSi","html_url":"https://github.com/BsNoSi","followers_url":"https://api.github.com/users/BsNoSi/followers","following_url":"https://api.github.com/users/BsNoSi/following{/other_user}","gists_url":"https://api.github.com/users/BsNoSi/gists{/gist_id}","starred_url":"https://api.github.com/users/BsNoSi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BsNoSi/subscriptions","organizations_url":"https://api.github.com/users/BsNoSi/orgs","repos_url":"https://api.github.com/users/BsNoSi/repos","events_url":"https://api.github.com/users/BsNoSi/events{/privacy}","received_events_url":"https://api.github.com/users/BsNoSi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/datenstrom/yellow/labels/suggestion","name":"suggestion","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-05T09:55:33Z","updated_at":"2015-11-04T14:55:42Z","closed_at":null,"body":"Hi,\r\n\r\nI am trying to go into deep with Yellow and created my first own plugin for adding style class into generated code. My PHP knowledge is „beginner status“, so I currently have no idea, how to solve it \"nice\".\r\n\r\nI want to add formating into my parsed markdown. Therefore I created a plugin (to be true: modified an existing one) with this main function:\r\n\r\n~~~{.php}\r\n\r\nfunction onParseContentBlock($page, $name, $text, $shortcut)\r\n\t{\r\n\t\t$output = NULL;\r\n\t\tif($name==\"format\" && $shortcut)\r\n\t\t{\r\n\t\t\tlist($class, $style) = $this->yellow->toolbox->getTextArgs($text);\r\n      if($class == \"end\" || $class == \"/\")\r\n       {\r\n       $output = \"<div></div></div>\";  \r\n//     $output = \"</div>\";  // creates wrong html code, \"<p></div></p>\"\r\n     }\r\n      else\r\n      {\r\n        $output = \"<div class=\\\"\".htmlspecialchars($class).\"\\\"\";\r\n\t\t\t  if($style) $output .= \" style=\\\"\".htmlspecialchars($style).\"\\\"\";\r\n\t\t\t  $output .= \">\";\r\n      }\r\n\t\t}\r\n\t\treturn $output;\r\n\t}\r\n\r\n~~~\r\n\r\nStarting the div with `[format classname]` creates a line as expected:\r\n\r\n~~~{.html}\r\n\r\n<div class=\"classname\">\r\n\r\n~~~\r\n\r\nTo achieve valid html, the closing parameter with `[format end]` or `[format /]` requires as $output\r\n\r\n~~~{.html}\r\n\r\n<div></div></div>\r\n\r\n~~~\r\n\r\nbecause a simple `</div>` is parsed into `<p></div></p>` in the final output.\r\n\r\nFor security reasons, I want to keep \"parserSafeMode = 1\" , so option `markdown=\"1\"` in the output of opening tag does not heal this, if it is not set to \"0\".\r\n\r\nIn general, the code delievers, what I want. But I want to understand, what is happening there. Any hints to improve this welcome.\r\n\r\nNoSi\r\n"},"comment":{"url":"https://api.github.com/repos/datenstrom/yellow/issues/comments/153752470","html_url":"https://github.com/datenstrom/yellow/issues/107#issuecomment-153752470","issue_url":"https://api.github.com/repos/datenstrom/yellow/issues/107","id":153752470,"user":{"login":"markseu","id":2429165,"avatar_url":"https://avatars.githubusercontent.com/u/2429165?v=3","gravatar_id":"","url":"https://api.github.com/users/markseu","html_url":"https://github.com/markseu","followers_url":"https://api.github.com/users/markseu/followers","following_url":"https://api.github.com/users/markseu/following{/other_user}","gists_url":"https://api.github.com/users/markseu/gists{/gist_id}","starred_url":"https://api.github.com/users/markseu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markseu/subscriptions","organizations_url":"https://api.github.com/users/markseu/orgs","repos_url":"https://api.github.com/users/markseu/repos","events_url":"https://api.github.com/users/markseu/events{/privacy}","received_events_url":"https://api.github.com/users/markseu/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T14:55:42Z","updated_at":"2015-11-04T14:55:42Z","body":"A third alternative could be a [wrapper](michelf/php-markdown#191), it creates an invisible DIV and parses content as usual:\r\n\r\n~~~\r\n::: columns\r\n-   First column with two paragraphs. Lorem ipsum dolor sit amet, \r\n    consectetur adipisicing elit, sed do eiusmod tempor incididunt \r\n    ut labore et dolore magna pizza.\r\n\r\n    Ubicumque homo est, ibi benefici locus est.\r\n\r\n-   Second column, just one paragraph.\r\n\r\n-   Third column has an image and a list.\r\n\r\n    [image icon.png]\r\n\r\n    1.  first list item\r\n    2.  second list item\r\n:::\r\n~~~\r\n\r\nThe third syntax is possible with the Markdown plugin, but it would need a couple of changes in the Markdown library. What's interesting about this approach, it would be easy-to-read and very flexible, just one syntax and no need to invent more plugins."}}