[0m tags in the HTML output. For
522 | example, this input:
523 |
524 | [32;1m┃ [0m* Bird
525 | [32;1m┃ [0m* Magic
526 |
527 | will turn into:
528 |
529 | [32;1m┃ [0m
603 |
604 | It's worth noting that it's possible
605 | to trigger an ordered list by
606 | accident, by writing something like
607 | this:
608 |
609 | [32;1m┃ [0m1986. What a great season.
610 |
611 | In other words, a
612 | [3mnumber-period-space[23m sequence at the
613 | beginning of a line. To avoid this,
614 | you can backslash-escape the period:
615 |
616 | [32;1m┃ [0m1986\. What a great season.
617 |
618 | [92m1.2.5 Code Blocks[0m
619 |
620 | Pre-formatted code blocks are used
621 | for writing about programming or
622 | markup source code. Rather than
623 | forming normal paragraphs, the lines
624 | of a code block are interpreted
625 | literally. Markdown wraps a code
626 | block in both [44;3m[0m and [44;3m[0m tags.
627 |
628 | To produce a code block in Markdown,
629 | simply indent every line of the
630 | block by at least 4 spaces or 1 tab.
631 | For example, given this input:
632 |
633 | [32;1m┃ [0mThis is a normal paragraph:
634 | [32;1m┃ [0m
635 | [32;1m┃ [0m This is a code block.
636 |
637 | Markdown will generate:
638 |
639 | [32;1m┃ [0mThis is a normal paragraph:
640 | [32;1m┃ [0m
641 | [32;1m┃ [0mThis is a code block.
642 | [32;1m┃ [0m
643 |
644 | One level of indentation -- 4 spaces
645 | or 1 tab -- is removed from each
646 | line of the code block. For example,
647 | this:
648 |
649 | [32;1m┃ [0mHere is an example of AppleScript:
650 | [32;1m┃ [0m
651 | [32;1m┃ [0m tell application "Foo"
652 | [32;1m┃ [0m beep
653 | [32;1m┃ [0m end tell
654 |
655 | will turn into:
656 |
657 | [32;1m┃ [0mHere is an example of
658 | [32;1m┃ [0mAppleScript:
659 | [32;1m┃ [0m
660 | [32;1m┃ [0mtell application "Foo"
661 | [32;1m┃ [0m beep
662 | [32;1m┃ [0mend tell
663 | [32;1m┃ [0m
664 |
665 | A code block continues until it
666 | reaches a line that is not indented
667 | (or the end of the article).
668 |
669 | Within a code block, ampersands ([44;3m&[0m)
670 | and angle brackets ([44;3m<[0m and [44;3m>[0m) are
671 | automatically converted into HTML
672 | entities. This makes it very easy to
673 | include example HTML source code
674 | using Markdown -- just paste it and
675 | indent it, and Markdown will handle
676 | the hassle of encoding the
677 | ampersands and angle brackets. For
678 | example, this:
679 |
680 | [32;1m┃ [0m
684 |
685 | will turn into:
686 |
687 | [32;1m┃ [0m<div
688 | [32;1m┃ [0mclass="footer">
689 | [32;1m┃ [0m © 2004 Foo
690 | [32;1m┃ [0mCorporation
691 | [32;1m┃ [0m</div>
692 | [32;1m┃ [0m
693 |
694 | Regular Markdown syntax is not
695 | processed within code blocks. E.g.,
696 | asterisks are just literal asterisks
697 | within a code block. This means
698 | it's also easy to use Markdown to
699 | write about Markdown's own syntax.
700 |
701 | [92m1.2.6 Horizontal Rules[0m
702 |
703 | You can produce a horizontal rule
704 | tag ([44;3m
[0m) by placing three or
705 | more hyphens, asterisks, or
706 | underscores on a line by themselves.
707 | If you wish, you may use spaces
708 | between the hyphens or asterisks.
709 | Each of the following lines will
710 | produce a horizontal rule:
711 |
712 | [32;1m┃ [0m* * *
713 | [32;1m┃ [0m
714 | [32;1m┃ [0m***
715 | [32;1m┃ [0m
716 | [32;1m┃ [0m*****
717 | [32;1m┃ [0m
718 | [32;1m┃ [0m- - -
719 | [32;1m┃ [0m
720 | [32;1m┃ [0m----------------------------------
721 | [32;1m┃ [0m-----
722 | [32;1m┃ [0m
723 | [32;1m┃ [0m_ _ _
724 |
725 | ────────────────────────────────────
726 |
727 | [32;1m1.3 Span Elements[0m
728 |
729 | [92m1.3.1 Links[0m
730 |
731 | Markdown supports two style of
732 | links: [3minline[23m and [3mreference[23m.
733 |
734 | In both styles, the link text is
735 | delimited by [square brackets].
736 |
737 | To create an inline link, use a set
738 | of regular parentheses immediately
739 | after the link text's closing square
740 | bracket. Inside the parentheses,
741 | put the URL where you want the link
742 | to point, along with an [3moptional[23m
743 | title for the link, surrounded in
744 | quotes. For example:
745 |
746 | [32;1m┃ [0mThis is [an
747 | [32;1m┃ [0mexample](http://example.com/
748 | [32;1m┃ [0m"Title") inline link.
749 | [32;1m┃ [0m
750 | [32;1m┃ [0m[This link](http://example.net/)
751 | [32;1m┃ [0mhas no title attribute.
752 |
753 | Will produce:
754 |
755 | [32;1m┃ [0mThis is
758 | [32;1m┃ [0man example inline link.
759 | [32;1m┃ [0m
760 | [32;1m┃ [0mThis
762 | [32;1m┃ [0mlink has no
763 | [32;1m┃ [0mtitle attribute.
764 |
765 | If you're referring to a local
766 | resource on the same server, you can
767 | use relative paths:
768 |
769 | [32;1m┃ [0mSee my [About](/about/) page for
770 | [32;1m┃ [0mdetails.
771 |
772 | Reference-style links use a second
773 | set of square brackets, inside which
774 | you place a label of your choosing
775 | to identify the link:
776 |
777 | [32;1m┃ [0mThis is [an example][id]
778 | [32;1m┃ [0mreference-style link.
779 |
780 | You can optionally use a space to
781 | separate the sets of brackets:
782 |
783 | [32;1m┃ [0mThis is [an example] [id]
784 | [32;1m┃ [0mreference-style link.
785 |
786 | Then, anywhere in the document, you
787 | define your link label like this, on
788 | a line by itself:
789 |
790 | [32;1m┃ [0m[id]: http://example.com/
791 | [32;1m┃ [0m"Optional Title Here"
792 |
793 | That is:
794 | [32m• [0mSquare brackets containing the
795 | link identifier (optionally
796 | indented from the left margin
797 | using up to three spaces);
798 | [32m• [0mfollowed by a colon;
799 | [32m• [0mfollowed by one or more spaces (or
800 | tabs);
801 | [32m• [0mfollowed by the URL for the link;
802 | [32m• [0moptionally followed by a title
803 | attribute for the link, enclosed
804 | in double or single quotes.
805 |
806 | The link URL may, optionally, be
807 | surrounded by angle brackets:
808 |
809 | [32;1m┃ [0m[id]:
810 | [32;1m┃ [0m"Optional Title Here"
811 |
812 | You can put the title attribute on
813 | the next line and use extra spaces
814 | or tabs for padding, which tends to
815 | look better with longer URLs:
816 |
817 | [32;1m┃ [0m[id]: http://example.com/longish/p
818 | [32;1m┃ [0math/to/resource/here
819 | [32;1m┃ [0m "Optional Title Here"
820 |
821 | Link definitions are only used for
822 | creating links during Markdown
823 | processing, and are stripped from
824 | your document in the HTML output.
825 |
826 | Link definition names may constist
827 | of letters, numbers, spaces, and
828 | punctuation -- but they are [3mnot[23m case
829 | sensitive. E.g. these two links:
830 |
831 | [32;1m┃ [0m[link text][a]
832 | [32;1m┃ [0m[link text][A]
833 |
834 | are equivalent.
835 |
836 | The [3mimplicit link name[23m shortcut
837 | allows you to omit the name of the
838 | link, in which case the link text
839 | itself is used as the name. Just use
840 | an empty set of square brackets --
841 | e.g., to link the word "Google" to
842 | the google.com web site, you could
843 | simply write:
844 |
845 | [32;1m┃ [0m[Google][]
846 |
847 | And then define the link:
848 |
849 | [32;1m┃ [0m[Google]: http://google.com/
850 |
851 | Because link names may contain
852 | spaces, this shortcut even works for
853 | multiple words in the link text:
854 |
855 | [32;1m┃ [0mVisit [Daring Fireball][] for more
856 | [32;1m┃ [0minformation.
857 |
858 | And then define the link:
859 |
860 | [32;1m┃ [0m[Daring Fireball]:
861 | [32;1m┃ [0mhttp://daringfireball.net/
862 |
863 | Link definitions can be placed
864 | anywhere in your Markdown document.
865 | I tend to put them immediately after
866 | each paragraph in which they're
867 | used, but if you want, you can put
868 | them all at the end of your
869 | document, sort of like footnotes.
870 |
871 | Here's an example of reference links
872 | in action:
873 |
874 | [32;1m┃ [0mI get 10 times more traffic from
875 | [32;1m┃ [0m[Google] [1] than from
876 | [32;1m┃ [0m[Yahoo] [2] or [MSN] [3].
877 | [32;1m┃ [0m
878 | [32;1m┃ [0m [1]: http://google.com/
879 | [32;1m┃ [0m"Google"
880 | [32;1m┃ [0m [2]: http://search.yahoo.com/
881 | [32;1m┃ [0m"Yahoo Search"
882 | [32;1m┃ [0m [3]: http://search.msn.com/
883 | [32;1m┃ [0m"MSN Search"
884 |
885 | Using the implicit link name
886 | shortcut, you could instead write:
887 |
888 | [32;1m┃ [0mI get 10 times more traffic from
889 | [32;1m┃ [0m[Google][] than from
890 | [32;1m┃ [0m[Yahoo][] or [MSN][].
891 | [32;1m┃ [0m
892 | [32;1m┃ [0m [google]: http://google.com/
893 | [32;1m┃ [0m"Google"
894 | [32;1m┃ [0m [yahoo]:
895 | [32;1m┃ [0mhttp://search.yahoo.com/ "Yahoo
896 | [32;1m┃ [0mSearch"
897 | [32;1m┃ [0m [msn]: http://search.msn.com/
898 | [32;1m┃ [0m"MSN Search"
899 |
900 | Both of the above examples will
901 | produce the following HTML output:
902 |
903 | [32;1m┃ [0mI get 10 times more traffic
904 | [32;1m┃ [0mfrom Google than
906 | [32;1m┃ [0mfrom
907 | [32;1m┃ [0mYahoo
909 | [32;1m┃ [0mor MSN.
912 |
913 | For comparison, here is the same
914 | paragraph written using Markdown's
915 | inline link style:
916 |
917 | [32;1m┃ [0mI get 10 times more traffic from
918 | [32;1m┃ [0m[Google](http://google.com/
919 | [32;1m┃ [0m"Google")
920 | [32;1m┃ [0mthan from
921 | [32;1m┃ [0m[Yahoo](http://search.yahoo.com/
922 | [32;1m┃ [0m"Yahoo Search") or
923 | [32;1m┃ [0m[MSN](http://search.msn.com/ "MSN
924 | [32;1m┃ [0mSearch").
925 |
926 | The point of reference-style links
927 | is not that they're easier to write.
928 | The point is that with
929 | reference-style links, your document
930 | source is vastly more readable.
931 | Compare the above examples: using
932 | reference-style links, the paragraph
933 | itself is only 81 characters long;
934 | with inline-style links, it's 176
935 | characters; and as raw HTML, it's
936 | 234 characters. In the raw HTML,
937 | there's more markup than there is
938 | text.
939 |
940 | With Markdown's reference-style
941 | links, a source document much more
942 | closely resembles the final output,
943 | as rendered in a browser. By
944 | allowing you to move the
945 | markup-related metadata out of the
946 | paragraph, you can add links without
947 | interrupting the narrative flow of
948 | your prose.
949 |
950 | [92m1.3.2 Emphasis[0m
951 |
952 | Markdown treats asterisks ([44;3m*[0m) and
953 | underscores ([44;3m_[0m) as indicators of
954 | emphasis. Text wrapped with one [44;3m*[0m or
955 | [44;3m_[0m will be wrapped with an HTML [44;3m[0m
956 | [3;44m[0m tag; double [44;3m*[0m's or [44;3m_[0m's will be
957 | wrapped with an HTML [44;3m[0m tag.
958 | E.g., this input:
959 |
960 | [32;1m┃ [0m*single asterisks*
961 | [32;1m┃ [0m
962 | [32;1m┃ [0m_single underscores_
963 | [32;1m┃ [0m
964 | [32;1m┃ [0m**double asterisks**
965 | [32;1m┃ [0m
966 | [32;1m┃ [0m__double underscores__
967 |
968 | will produce:
969 |
970 | [32;1m┃ [0msingle asterisks
971 | [32;1m┃ [0m
972 | [32;1m┃ [0msingle underscores
973 | [32;1m┃ [0m
974 | [32;1m┃ [0mdouble asterisks
975 | [32;1m┃ [0m
976 | [32;1m┃ [0mdouble
977 | [32;1m┃ [0munderscores
978 |
979 | You can use whichever style you
980 | prefer; the lone restriction is that
981 | the same character must be used to
982 | open and close an emphasis span.
983 |
984 | Emphasis can be used in the middle
985 | of a word:
986 |
987 | [32;1m┃ [0mun*fucking*believable
988 |
989 | But if you surround an [44;3m*[0m or [44;3m_[0m with
990 | spaces, it'll be treated as a
991 | literal asterisk or underscore.
992 |
993 | To produce a literal asterisk or
994 | underscore at a position where it
995 | would otherwise be used as an
996 | emphasis delimiter, you can
997 | backslash escape it:
998 |
999 | [32;1m┃ [0m\*this text is surrounded by
1000 | [32;1m┃ [0mliteral asterisks\*
1001 |
1002 | [92m1.3.3 Code[0m
1003 |
1004 | To indicate a span of code, wrap it
1005 | with backtick quotes ([44;3m`[0m). Unlike a
1006 | pre-formatted code block, a code
1007 | span indicates code within a normal
1008 | paragraph. For example:
1009 |
1010 | [32;1m┃ [0mUse the `printf()` function.
1011 |
1012 | will produce:
1013 |
1014 | [32;1m┃ [0mUse the printf()
1015 | [32;1m┃ [0mfunction.
1016 |
1017 | To include a literal backtick
1018 | character within a code span, you
1019 | can use multiple backticks as the
1020 | opening and closing delimiters:
1021 |
1022 | [32;1m┃ [0m``There is a literal backtick (`)
1023 | [32;1m┃ [0mhere.``
1024 |
1025 | which will produce this:
1026 |
1027 | [32;1m┃ [0mThere is a literal
1028 | [32;1m┃ [0mbacktick (`) here.
1029 |
1030 | The backtick delimiters surrounding
1031 | a code span may include spaces --
1032 | one after the opening, one before
1033 | the closing. This allows you to
1034 | place literal backtick characters at
1035 | the beginning or end of a code
1036 | span:
1037 |
1038 | [32;1m┃ [0mA single backtick in a code span:
1039 | [32;1m┃ [0m`` ` ``
1040 | [32;1m┃ [0m
1041 | [32;1m┃ [0mA backtick-delimited string in a
1042 | [32;1m┃ [0mcode span: `` `foo` ``
1043 |
1044 | will produce:
1045 |
1046 | [32;1m┃ [0mA single backtick in a code
1047 | [32;1m┃ [0mspan: `
1048 | [32;1m┃ [0m
1049 | [32;1m┃ [0mA backtick-delimited string in
1050 | [32;1m┃ [0ma code span:
1051 | [32;1m┃ [0m`foo`
1052 |
1053 | With a code span, ampersands and
1054 | angle brackets are encoded as HTML
1055 | entities automatically, which makes
1056 | it easy to include example HTML
1057 | tags. Markdown will turn this:
1058 |
1059 | [32;1m┃ [0mPlease don't use any `