jakubgarfield / Bonobo-Git-Server

Bonobo Git Server for Windows is a web application you can install on your IIS and easily manage and connect to your git repositories. Go to homepage for release and more info.
http://bonobogitserver.com
MIT License
1.81k stars 603 forks source link

Markdown <pre> interpreted as <code> not working with backtick. #382

Closed aaroncalderon closed 8 years ago

aaroncalderon commented 8 years ago

Issue

I have a Readme.md file on one of my repositories. A snippet of the mark down is as follows:

```
git clone http://localhost/git/n-ldapjs.git
   cd n-ldapjs 
npm install
```

Expecting the block to be interpreted as <pre>, like enclosed in three backticks ```. But the code shows interpreted as <code> and shows as: git clone http://localhost/git/n-ldapjs.git cd n-ldapjs npm install As if only one backtick was used.

I realize that I can also indent the text with four spaces and acheive the same <pre></pre> rendering, but I'm trying to document my repositories and I am used to many of the features from GitHub. Just wondering if there could be a way to address this.

Work Around

As a work around I can use the HTML tag <pre>$code.goes.here() </pre>, or indent by four spaces, but I would expect similar Markdown features from the Bonobo since it replaces GitHub on my server.

Conclusion

In the end this will boil down to a feature request. Since, there is a way to achieve the same end result, but in my opinion, the desired similarity between Git's and Gonobo's Markdown interpreters is strong.

Thanks.

Update:

I reviewed the code and seems that Bonobo uses MarkdownDeep to support displaying markdown pages in the repositories. So, the use of three backticks to define a code block is not part of the markdown implementation.

RedX2501 commented 8 years ago

Maybe you should open an issue with the MarkdownDeep developers and close this issue.

aaroncalderon commented 8 years ago

Well,

MarkdownDeep's emphases is to support the markdown standard as defined by Daring Fireball on his website. But, as I mentioned above, Bonobo-Git-Server aims at being a Git implementation for Windows, kind of GitHub-ish, or at least I think it should. So, I think Bonobo-Git-Server users will expect this to be a feature since GitHub Markdown would be the familiar markdown we are used to.

I myself looked into this and found a way to use a JavaScript library, marked to gain some additional GitHub Markdown features on Gonobo-Git-Server.

My approach completely replaces the current MarkdownDeep implementation, so I do not know if a Pull Request would be welcomed.

If anything, I would like to look in to it further and add an option to either use MarkdownDeep or marked.

Or better yet, use marked as the only markdown implementation and use its options to choose to parse markdown as 'standard' markdown or GitHub Markdown. But, I have not had the time to work on that right now. When I do, I will send a Pull Request for sure.

Regards

Update

I have reviewed the code base and I have a good idea of what needs to be done to add the setting and functionality. But I am not familiar with the process of getting all the changes compiled or tested since I would need to edit files like SettingsController.cs, SettingsModel.cs and possibly others, so I would have to halt my efforts in pursuit of this feature as a contribution to the project.

At least let me outline what I did to get marked working on my installation.

I saved the file marked.js on Bonobo.Git.Server\Content\js\marked.js. Then I edited the following two files: Views/Repository/Blob.cshtml line 28

<div class="markdown">@Html.MarkdownToHtml(Model.Text)</div>

with

<div id="markedsrc">@Model.Text</div>
<script src="~/Content/js/marked.js"></script>
<script>
  document.getElementById('markedsrc').innerHTML = marked(document.getElementById('markedsrc').innerHTML, {
    gfm: true,
    tables: true,
    breaks: false,
    pedantic: false,
    sanitize: true,
    smartLists: true,
    smartypants: true});
</script>

Views/Repository/Tree.cshtml line 44

<div class="markdown">@Html.MarkdownToHtml(Model.Readme)</div>

with

<div id="markedsrc">@Model.Readme</div>
<script src="~/Content/js/marked.js"></script>
<script>
  document.getElementById('markedsrc').innerHTML = marked(document.getElementById('markedsrc').innerHTML, {
    gfm: true,
    tables: true,
    breaks: false,
    pedantic: false,
    sanitize: true,
    smartLists: true,
    smartypants: true});
</script>

And that gets me the GitHub like rendering of markdown.

Thanks.