html文件中可以有多个h1?

html文件中可以有多个h1?

我记忆中只能有一个。所以,我的文件,我默认为title是h1,正文的标题我都从h2开始。这样实际我的文章中没有h1标签。

今天查了一下,发现一篇文章中可以有多个h1。而且应该从h1开始。:(
http://www.w3.org/TR/REC-html40/struct/global.html

Every HTML document must have a TITLE element in the HEAD section.

Authors should use the TITLE element to identify the contents of a document. Since users often consult documents out of context, authors should provide context-rich titles. Thus, instead of a title such as "Introduction", which doesn't provide much contextual background, authors should supply a title such as "Introduction to Medieval Bee-Keeping" instead.

关于titile。

Some people consider skipping heading levels to be bad practice. They accept H1 H2 H1 while they do not accept H1 H3 H1 since the heading level H2 is skipped.

这里并没说跳过某级heading是错误的,但说有些人觉得这样不好。恰巧我就是有些人中的一元。

这对我很不利!1)我以前的文章不和规范 2)我实际用emacs markdown-mode写作。而且把所有条目都集中在一个文本文件中。我靠h1区别每篇文章。而且在折起文章是,可以直接kill h1,就把整篇文章内容复制到剪贴板了。贴到浏览器中很方便。

所以,我还是准备继续保持从h2开始。或者我去修改模板,把title两边加上h1。但w3c说title不能有修饰的tag!:(

我明白了,我需要修改模板,让title还是不做任何修饰。在body开始的时候,来一个

  <h1>$print title</h1>

看看行不行。

我现在的站点的markup语句是正确的(valid)0

markdown一个list的项目如果是好几个段落,段落前面要留一个空格

markdown一个list的项目如果是好几个段落,段落前面要留一个空格

举个例子

想要达到下面的list效果

  1. 第一段

    第二段

  2. 第三段

  3. 第四段

    第五段

    第六段

  4. 第7段

  5. 第8段

一共8段,list有5个item。

它的markdown源文件是这样的

  1. 第一段

   第二段

  1.  第三段

  1.  第四段

   第五段

   第六段

  1. 第7段

  1. 第8段

markdown中numbered-list,就是编号的列表前面的数字不需要是按顺序的,是个阿拉伯数字加个英文句号跟一个空格就可以了。所以,都写 1. 最方便。这样即使你从中间加入一个item,自己也不会觉得乱。

还有,同一个list item中从第2个段落开始开头要缩进一个空格。2个也可以,只要不超过7个不到达8个都行。因为开头连续8个空格就是markdown中表示html的code这个tag的语法了。我建议统一留一个,保持你文档整体风格。

注意:一般情况下,开头6个空格就表示改行应该用html中code这个tag。但在list中,需要8个。 这是我刚才一个一个试出来的。markdown文档中没有明确地写!

不留空格是错误的

注意到了么,第二、五、六段前面我留了一个空格。不留空格就不对了。我们看看不留空格的效果。

不留空格的源文件是:

  1. 第一段

  第二段

  1.  第三段

  1.  第四段

  第五段

  第六段

  1. 第7段

  1. 第8段

效果是:

  1. 第一段

第二段

  1. 第三段

  2. 第四段

第五段

第六段

  1. 第7段

  2. 第8段

看到了么。markdown认为中间顶头的几段(说它们是段落因为它们中间有空行分开,所以不管几个字,都是段落。我写很少几个字是为了节约时间。其长度是不限制的)分开了几个list。它这么认为是正确地。因为本来就是这么设计的。你不这么设计,只要开头出现list,全文都成了list item了。

**注意:一般情况下,开头6个空格就表示改行应该用html中code这个tag。

自己细读markdown syntax都写得很清楚

我记一笔加深自己记忆。今天正好碰到类似情况。开始没搞对,后来记忆中有空格这个要求,试了一下,就对了。

如果你要表示的是nested list

我写得很清楚:markdown语法中如何表示嵌套的列表(nested lists)

markdown语法中如何表示嵌套的列表(nested lists)也没有定义列表(definition list)?

markdown语法中如何表示嵌套的列表(nested lists)也没有定义列表(definition list)?

今天需要用到nested lists才发现这个问题。markdown正是网站给的信息里肯定没有: http://daringfireball.net/projects/markdown/syntax

不知道有没有什么work-around呀。

查了一下,nested lists要求下一级的list有4个空格做indent就好了

参阅

http://six.pairlist.net/pipermail/markdown-discuss/2007-July...
There's no limit to nesting; Markdown just seems to be confused by
your indentation. Make sure you always indent each successive nesting
level exactly four spaces, and everything will work fine:

markdown的syntax页面没有提到nest lists,但dingus页面却提到了。markdown项目应该及时更新一下syntx页面了。

http://daringfireball.net/projects/markdown/dingus

You can nest them:

  • Abacus
    • answer
  • Bubbles
    1. bunk
    2. bupkis
      • BELITTLER
    3. burper
  • Cunning

definition list只是在php markdown extra中才有

到2008年6月,markdwon和基于markdown的emacs markdwon-mode中还没有相应语法。

** markdown-mode语法

** markdown-mode语法

Anchors (C-c C-a)
C-c C-a l
Creates an inline link. If there is an active region,
this text will be used as the anchor text
(markdown-insert-link).

Commands (C-c C-c)
C-c C-c m
Run markdown on the current buffer and preview the output in
another buffer (markdown).
C-c C-c p
Run markdown on the current buffer and preview the output in
a browser (markdown-preview).

Images (C-c C-i)
C-c C-i i
Insert an image, using the current region (if any) as the alt
text (markdown-insert-image).

** html2text: 把html语法格式转换成更方便阅读和编辑的mrakdown语法格式的工具

** html2text: 把html语法格式转换成更方便阅读和编辑的mrakdown语法格式的工具

http://www.aaronsw.com/2002/html2text/

THE ASCIINATOR
html2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to be valid Markdown (a text-to-HTML format).

Also known as: html to text, htm to txt, htm2txt, ...

太有用了。直接把网页的html转换成markdown语法格式的。方便再利用和翻译。
可以下载这个工具,也可以直接让它在线转换。

在markdown中需要用连续5个反斜扛 \\\\\ 表示连续两个反斜杠 \\

先说一下,drupal我启用了markdown,文章正文输入格式是markdown,题目中无法用markdown,这也好,要不我怎么表示连续5个backslash呀。

发现的现象

在markdown中需要用连续5个反斜扛

    \\\\\ 

表示连续两个反斜杠

     \\

这篇文章的时候我用到了

   \\character

这种格式。就是两个英文反斜杠后面跟一段字符。才发现在markdown中要正确显示两个反斜杠需要在用5个back slash!!

原因?我还不清楚。但我测试结果是5个一下back slash最后都被解析为1个back slash。

我猜想的原因

2个\ 第一个\用来escape第2个\,所以最后剩下1个\

3个\ 第一个\用来escape第2个了,前两个生成的\用来escape第3个\,最后剩下一个\

4个\ 第一个\用来escape第2个了,前两个生成的\用来escape第3个\, 前3个生成的\用来escape第4个\,最后剩下一个\ 更有可能是前2个\变成1个\,后2个\变成1个\ 生成的这2个\,前一个escape后面的\,最后1个\。

4个\ 第一个\用来escape第2个了,前两个生成的\用来escape第3个\, 前3个生成的\用来escape第4个\,这个\就不去escape第5个\,所以最后剩下2个!也有可能4个\变成1个,这个和第5个一起组成2个\。

这个现象似乎在哪里看到过。是grep中也是这样么?

谁能解释一下!

反正今天我才知道。

我搜索了一下,markdown官方文档没有说如何表示两个\连在一起,但有人在邮件列表说到这个情况,提议

As an aside, this makes me think that there's a small integration
problem when using Markdown with SmartyPants that makes it necessary
in many cases to double-escape a litteral character so that
SmartyPants ignores it:

\\\\\ two backslashes
\\\`` two backticks
\\-- two hyphens
\\... three dots

Maybe Markdown should convert escaped characters to their numerical
entity equivalent (like SmartyPants does) so that the escape
propagates to SmartyPants too without requiring two more backslashes.
http://six.pairlist.net/pipermail/markdown-discuss/2007-Janu...

我这页中都把含有 \ 的行另起一段,并在前面加6个空格,这在markdown中是说这行是代码,不要做任何解释,启用相当于

  <pre><code>这里是代码</code></pre>

我最后问一个问题

你们看如何表示5个连续反斜刚,10个呢?:)谁找到规律了。

我特别喜欢markdown

markown是我不可缺少的工具。我用它写标准文章,最后生成标准的html页面。特好!这里说它一个不方便的地方希望不要打击大家去试用markdown的热情。我感觉它比wiki输入法都方便。

markdown解析url中含有下划线 "_" 出现的问题已经解决了

update: 20080610

这篇文章写的很不明白。而且提到的问题在新版本的durpal和markdown中已经没有了

我重新简单说一下。

当时4.7版本的问题

老版本的markdown,drupal 4.7 版本的,如果你常遇到wikipedia上的文章url没能被markdown正常解释。原因是该url中有2条下划线,这是wikipedia命名多个单词的entry的方式。那么你可以把该url放在英文尖括号中,就不会出现问题了。

现在我用的drupal 6.0和相应版本的markdown,已经没有这个问题了。

比如
http://en.wikipedia.org/wiki/_Hamad_bin_Khalifa
http://en.wikipedia.org/wiki/George_W._Bush

加上<>让它正确显示
http://en.wikipedia.org/wiki/Hamad_bin_Khalifa
http://en.wikipedia.org/wiki/George_W._Bush

这2个url中都有两个下划线包着一个单词。都正常。

现在加<>的好处只是让该url完整显示而不受url filter截取前多少个字符的限制。这对直接贴wikipedia的链接也有好处,大家一幕了然文章内容了。:)

end


markdown解析url中含有下划线 "_" 出现的问题已经解决了

teradome虽然对我几个月前报的问题回复很慢,但帮我解决了。真好。我当时报的问题在这里 http://drupal.org/node/92111

markdown的语法中两个下划线中的词是强调的意思。所以,如果你直接贴的网址中有两个和以上的下划线,如:

http://the.url.com/some_location/a_file.html

就不会被解析成正确的网址,而是把两个下划线中间的部分给解析成强调了。 如:
http://the.url.com/some_location/a_file.html

解决方法呢?2个

方法一:

方法就是用英文尖括号<>把含有下划线的url个括起来就好
http://the.url.com/some_location/a_file.html

就是
http://the.url.com/some_location/a_file.html

方法二:
用反斜杠 \ 放在下划线 前面告诉markdown不要解析下划线
http://the.url.com/some_location/a_file.html

这个你看不到 http:// 是因为我请小拉定制了一个urlfilter切掉所有的http:// 了 (You don't see the http:// in this instance because i asked xiaola to make a customerized version of urlfilter which cuts off all the http:// )

就是这样.下面是terdome的回复

I can't tell from your report if this occurs in an anchor tag or as
free-form text. I do know that free-form linking should be formatted
as http://the.url.com/some_location/a_file.html but depending what
else is in your input format (e.g., HTML Filter) this may get stripped.

I am using html filter and <> doesn't get stripped.

If this is standard text, you may need to use backslash escapes to
preserve the underscore, such as
http://the.url.com/some_location/a_file.html -- this is a standard
Markdown feature.

problem solved. :)

teradome

you the man~ xiexie~(meaning thanks)

http://the.url.com/some_location/a_file.html

http://the.url.com/some_location/a_file.html

刚才第一次用markdown的2个链接套在一起

edvard munch,就是画 the scream 的那个人我想显示一张小图,点小图连到大图。第一次用markdown来实现。以前没有这种需要。方法很简单。就是

 链接tag []() 

中间套一个

 贴图的tag ![]()

就是这样

  [![](小图片的url)](大图片的url)

我觉得这种方法很简单。我很习惯了markdown的语法。关键是他的原文件,就是带着他tag符号的文本文件就能直接看懂和编辑,而其语法很少,很简单。

markdown一种方便你写标准的html文件的工具。

Daring Fireball: Markdown
http://daringfireball.net/projects/markdown/

这里输入个是可以选用markdown。反正我一直用。:)以后也用。我第一次认识到他并在blosoxm上正确装上了他的插件和使用出来的时候。真是兴奋啊~! :)那是今年2月的事情了吧。