Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

git - Add gray area in markdown

I currently editing readme.md file and I want to put for some text block gray area like this.

They used the ```javascript annotation to start writing in gray but the problem occurs when you need to add links to the texts.

Is there another option to provide a gray frame?

UPDATE:

Security

- Abstract

Lets say that I want that the Test 123 text and the follow will be inside a gray area(like code) how do I achieve this? the problem here is with the URL in the follow section...

update 2

## Test 
   <a name="Test"></a><a name="1.1"></a>
   - **Abstract**
    - Test 123
    - Follow  [testing artifacts](http://2.bp.blogspot.com) (more Unit )
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The behavior you point to is using a code block. A code block's sole purpose it to display raw code. The fact that GitHub chose to apply a style which changed the background color to gray is coincidental. They could have easily chosen any other color or none at all.

If you want a block of text to stand out as different but still be rendered as normal Markdown text, then you absolutely do not want a code block. There are a few other options available.

You could use a blockquote:

 > - Test 123
 > - Follow  [testing artifacts](http://2.bp.blogspot.com) (more Unit )

Again, the actual styling will depend on the styles defined on the site you are posting your Markdown to. Each site may be different. Here on StackOverflow you get a yellow (orange?) box, like this:

On GitHub you get a gray bar on the left and no background shading, but that is the best you can probably do.

Another alternative is to use raw HTML to define your own block. However, for security reasons, GitHub will strip that out.

GitHub probably won't strip out a simple <div>, but there are various other problems. First of all, as per the Markdown rules, "Markdown formatting syntax is not processed within block-level HTML tags." While some Markdown implementations have added a way to force Markdown processing within block-level HTML, it does not appear that GitHub supports any of them.

And then there is the issue of how to style the div. You could assign a class, but then how do you define the CSS to style that class? You can't include CSS in your Markdown (GitHub will strip that out). While one could include inline styles (using the style attribute on the div), GitHub stips the style attribute out as well.

If you really want full control over how your document looks, then you need to host your own site on your own server. When using sites like GitHub, you are stuck with their choices.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...