{"action":"created","issue":{"url":"https://api.github.com/repos/PrismJS/prism/issues/608","labels_url":"https://api.github.com/repos/PrismJS/prism/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/PrismJS/prism/issues/608/comments","events_url":"https://api.github.com/repos/PrismJS/prism/issues/608/events","html_url":"https://github.com/PrismJS/prism/issues/608","id":91069650,"number":608,"title":"Indentation","user":{"login":"brentonstrine","id":1900802,"avatar_url":"https://avatars.githubusercontent.com/u/1900802?v=3","gravatar_id":"","url":"https://api.github.com/users/brentonstrine","html_url":"https://github.com/brentonstrine","followers_url":"https://api.github.com/users/brentonstrine/followers","following_url":"https://api.github.com/users/brentonstrine/following{/other_user}","gists_url":"https://api.github.com/users/brentonstrine/gists{/gist_id}","starred_url":"https://api.github.com/users/brentonstrine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brentonstrine/subscriptions","organizations_url":"https://api.github.com/users/brentonstrine/orgs","repos_url":"https://api.github.com/users/brentonstrine/repos","events_url":"https://api.github.com/users/brentonstrine/events{/privacy}","received_events_url":"https://api.github.com/users/brentonstrine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-06-25T20:37:51Z","updated_at":"2015-06-26T05:15:00Z","closed_at":null,"body":"Because of the use of `<pre>`, multiline code needs to be unindented. When working in a fairly large file with a lot of different code examples, this really makes things confusing. I rely on indentation to find my place in a document, and so I get confused easily.\r\n\r\nSource code is ugly:\r\n```html\r\n<body>\r\n    <main>\r\n        <section>\r\n            <p>Lorem ipsum</p>\r\n            <pre><code>\r\n.demo {}\r\n.demo2{}\r\n            </code></code>\r\n            <div>\r\n                <p>Lorem ipsum</p>\r\n                <pre><code>\r\n.demo {}\r\n.demo2{}\r\n                </code></code>\r\n            </div>\r\n        </section>\r\n    </main>\r\n</body>\r\n```\r\n\r\nCode output is pretty:\r\n\r\n````css\r\n.demo {}\r\n.demo2{}\r\n```\r\n\r\n\r\nIf the code is indented as expected, then the actual output gets indented that much as well.\r\n\r\nSource code is pretty:\r\n```html\r\n<body>\r\n    <main>\r\n        <section>\r\n            <p>Lorem ipsum</p>\r\n            <pre><code>\r\n                .demo {}\r\n                .demo2{}\r\n            </code></code>\r\n            <div>\r\n                <p>Lorem ipsum</p>\r\n                <pre><code>\r\n                    .demo {}\r\n                    .demo2{}\r\n                </code></code>\r\n            </div>\r\n        </section>\r\n    </main>\r\n</body>\r\n```\r\nCode output is ugly:\r\n````css\r\n                    .demo {}\r\n                    .demo2{}\r\n```\r\n\r\nI wrote some Javascript that calculates the number of spaces on the first line, and strips that amount of space off of all lines. I think it could be a plugin or integrated directly into the core, but I see that it needs to be rewritten, because it's current format does not match style.\r\n\r\n```javascript\r\nvar toFix = document.getElementsByClassName(\"indentFix\");\r\nfor(var elem = 0, elems = toFix.length; elem<elems; elem++){\r\n    var lines = toFix[elem].innerHTML.split(\"\\n\");\r\n    var line = lines[1];\r\n    var leadingSpaces = 1;\r\n    while(line.charAt(leadingSpaces)==\" \"){leadingSpaces++;}\r\n    for(var i = 1, len=lines.length;i<len;i++){\r\n        lines[i] = lines[i].slice(leadingSpaces);\r\n    }\r\n    toFix[elem].innerHTML = lines.join(\"\\n\");\r\n}\r\n```\r\nSource code is pretty:\r\n```html\r\n<body>\r\n    <main>\r\n        <section>\r\n            <p>Lorem ipsum</p>\r\n            <pre><code class=\"indentFix\">\r\n                .demo {}\r\n                .demo2{}\r\n            </code></code>\r\n            <div>\r\n                <p>Lorem ipsum</p>\r\n                <pre><code class=\"indentFix\">\r\n                    .demo {}\r\n                    .demo2{}\r\n                </code></code>\r\n            </div>\r\n        </section>\r\n    </main>\r\n</body>\r\n```\r\nCode output is pretty:\r\n\r\n````css\r\n.demo {}\r\n.demo2{}\r\n```"},"comment":{"url":"https://api.github.com/repos/PrismJS/prism/issues/comments/115517285","html_url":"https://github.com/PrismJS/prism/issues/608#issuecomment-115517285","issue_url":"https://api.github.com/repos/PrismJS/prism/issues/608","id":115517285,"user":{"login":"vkbansal","id":5930351,"avatar_url":"https://avatars.githubusercontent.com/u/5930351?v=3","gravatar_id":"","url":"https://api.github.com/users/vkbansal","html_url":"https://github.com/vkbansal","followers_url":"https://api.github.com/users/vkbansal/followers","following_url":"https://api.github.com/users/vkbansal/following{/other_user}","gists_url":"https://api.github.com/users/vkbansal/gists{/gist_id}","starred_url":"https://api.github.com/users/vkbansal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkbansal/subscriptions","organizations_url":"https://api.github.com/users/vkbansal/orgs","repos_url":"https://api.github.com/users/vkbansal/repos","events_url":"https://api.github.com/users/vkbansal/events{/privacy}","received_events_url":"https://api.github.com/users/vkbansal/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T05:15:00Z","updated_at":"2015-06-26T05:15:00Z","body":"@Golmote May be put a note about it somewhere."}}