Show More
@@ -1,61 +1,63 b'' | |||
|
1 | 1 | import markdown |
|
2 | 2 | from markdown.inlinepatterns import Pattern |
|
3 | 3 | from markdown.util import etree |
|
4 | 4 | |
|
5 | 5 | __author__ = 'vurdalak' |
|
6 | 6 | |
|
7 | 7 | |
|
8 | 8 | class AutolinkPattern(Pattern): |
|
9 | 9 | def handleMatch(self, m): |
|
10 | 10 | link_element = etree.Element('a') |
|
11 | 11 | href = m.group(2) |
|
12 | 12 | link_element.set('href', href) |
|
13 | 13 | link_element.text = href |
|
14 | 14 | |
|
15 | 15 | return link_element |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | class QuotePattern(Pattern): |
|
19 | 19 | def handleMatch(self, m): |
|
20 | 20 | quote_element = etree.Element('span') |
|
21 | 21 | quote_element.set('class', 'quote') |
|
22 | 22 | quote_element.text = m.group(3) |
|
23 | 23 | |
|
24 | 24 | return quote_element |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | class ReflinkPattern(Pattern): |
|
28 | 28 | def handleMatch(self, m): |
|
29 | 29 | ref_element = etree.Element('a') |
|
30 | 30 | post_id = m.group(4) |
|
31 | 31 | ref_element.set('href', '#' + str(post_id)) |
|
32 | 32 | ref_element.text = '#' + post_id |
|
33 | 33 | |
|
34 | 34 | return ref_element |
|
35 | 35 | |
|
36 | 36 | |
|
37 | 37 | class NeboardMarkdown(markdown.Extension): |
|
38 | 38 | AUTOLINK_PATTERN = r'(http://\S+)' |
|
39 | 39 | QUOTE_PATTERN = r'(>){1}(.+)' |
|
40 | 40 | REFLINK_PATTERN = r'((>){2}(\d+))' |
|
41 | 41 | |
|
42 | 42 | def extendMarkdown(self, md, md_globals): |
|
43 | 43 | autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md) |
|
44 | 44 | quote = QuotePattern(self.QUOTE_PATTERN, md) |
|
45 | 45 | reflink = ReflinkPattern(self.REFLINK_PATTERN, md) |
|
46 | 46 | |
|
47 | 47 | md.inlinePatterns[u'autolink_ext'] = autolink |
|
48 |
md.inlinePatterns |
|
|
49 |
md.inlinePatterns |
|
|
48 | md.inlinePatterns.add(u'reflink', reflink, '<entity') | |
|
49 | md.inlinePatterns.add(u'quote', quote, '<entity') | |
|
50 | # md.inlinePatterns[u'reflink'] = reflink | |
|
51 | # md.inlinePatterns[u'quote'] = quote | |
|
50 | 52 | |
|
51 | del(md.inlinePatterns[u'entity']) | |
|
53 | # del(md.inlinePatterns[u'entity']) | |
|
52 | 54 | |
|
53 | 55 | |
|
54 | 56 | def makeExtension(configs=None): |
|
55 | 57 | return NeboardMarkdown(configs=configs) |
|
56 | 58 | |
|
57 | 59 | neboard_extension = makeExtension() |
|
58 | 60 | |
|
59 | 61 | |
|
60 | 62 | def markdown_extended(markup): |
|
61 | 63 | return markdown.markdown(markup, [neboard_extension]) |
@@ -1,182 +1,182 b'' | |||
|
1 | 1 | html { |
|
2 | 2 | background: #555; |
|
3 | 3 | color: #ffffff; |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | #admin_panel { |
|
7 | 7 | background: #FF0000; |
|
8 | 8 | color: #00FF00 |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | 11 | .title { |
|
12 | 12 | font-weight: bold; |
|
13 | 13 | color: #ffcc00; |
|
14 | 14 | } |
|
15 | 15 | |
|
16 | 16 | .link, a { |
|
17 | 17 | color: #afdcec; |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | .link:hover { | |
|
20 | .link:hover, a:hover { | |
|
21 | 21 | color: #fff380; |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | .post_id:hover { |
|
25 | 25 | color: #ccc555; |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | .block { |
|
29 | 29 | display: inline-block; |
|
30 | 30 | vertical-align: top; |
|
31 | 31 | } |
|
32 | 32 | |
|
33 | 33 | .tag { |
|
34 | 34 | color: #b4cfec; |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | .tag:hover { |
|
38 | 38 | color: #d0edb4; |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | .post_id { |
|
42 | 42 | color: #fff380; |
|
43 | 43 | } |
|
44 | 44 | |
|
45 | 45 | .post, .dead_post{ |
|
46 | 46 | background: #333; |
|
47 | 47 | margin: 5px; |
|
48 | 48 | padding: 10px; |
|
49 | 49 | border-radius: 5px; |
|
50 | 50 | clear: left; |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | .metadata { |
|
54 | 54 | padding: 5px; |
|
55 | 55 | margin-top: 10px; |
|
56 | 56 | border: solid 1px #666; |
|
57 | 57 | font-size: 0.9em; |
|
58 | 58 | color: #ddd; |
|
59 | 59 | display: table; |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | .navigation_panel { |
|
63 | 63 | background: #444; |
|
64 | 64 | margin: 5px; |
|
65 | 65 | padding: 10px; |
|
66 | 66 | border-radius: 5px; |
|
67 | 67 | color: #eee; |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 | .navigation_panel .link { |
|
71 | 71 | border-right: 1px solid #fff; |
|
72 | 72 | font-weight: bold; |
|
73 | 73 | margin-right: 1ex; |
|
74 | 74 | padding-right: 1ex; |
|
75 | 75 | } |
|
76 | 76 | .navigation_panel .link:last-child { |
|
77 | 77 | border-left: 1px solid #fff; |
|
78 | 78 | border-right: none; |
|
79 | 79 | float: right; |
|
80 | 80 | margin-left: 1ex; |
|
81 | 81 | margin-right: 0; |
|
82 | 82 | padding-left: 1ex; |
|
83 | 83 | padding-right: 0; |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | .navigation_panel::after, .post::after { |
|
87 | 87 | clear: both; |
|
88 | 88 | content: "."; |
|
89 | 89 | display: block; |
|
90 | 90 | height: 0; |
|
91 | 91 | line-height: 0; |
|
92 | 92 | visibility: hidden; |
|
93 | 93 | } |
|
94 | 94 | |
|
95 | 95 | p { |
|
96 | 96 | margin-top: .5em; |
|
97 | 97 | margin-bottom: .5em; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | .post-form-w { |
|
101 | 101 | display: table; |
|
102 | 102 | background: #333344; |
|
103 | 103 | border-radius: 5px; |
|
104 | 104 | color: #fff; |
|
105 | 105 | padding: 10px; |
|
106 | 106 | margin: 5px |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | .form-row { |
|
110 | 110 | display: table-row; |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | .form-label, .form-input { |
|
114 | 114 | display: table-cell; |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | .form-label { |
|
118 | 118 | padding: .25em 1ex .25em 0; |
|
119 | 119 | vertical-align: top; |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | .form-input { |
|
123 | 123 | padding: .25em 0; |
|
124 | 124 | } |
|
125 | 125 | |
|
126 | 126 | .post-form input, .post-form textarea { |
|
127 | 127 | background: #333; |
|
128 | 128 | color: #fff; |
|
129 | 129 | border: solid 1px; |
|
130 | 130 | padding: 0; |
|
131 | 131 | width: 100%; |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | .form-submit { |
|
135 | 135 | border-bottom: 2px solid #ddd; |
|
136 | 136 | margin-bottom: .5em; |
|
137 | 137 | padding-bottom: .5em; |
|
138 | 138 | } |
|
139 | 139 | |
|
140 | 140 | .form-title { |
|
141 | 141 | font-weight: bold; |
|
142 | 142 | } |
|
143 | 143 | |
|
144 | 144 | input[type="submit"] { |
|
145 | 145 | background: #222; |
|
146 | 146 | border: solid 1px #fff; |
|
147 | 147 | color: #fff; |
|
148 | 148 | } |
|
149 | 149 | |
|
150 | 150 | blockquote { |
|
151 | 151 | border-left: solid 2px; |
|
152 | 152 | padding-left: 5px; |
|
153 | 153 | color: #B1FB17; |
|
154 | 154 | margin: 0; |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | .post > .image { |
|
158 | 158 | float: left; margin: 0 1ex .5ex 0; |
|
159 | 159 | } |
|
160 | 160 | |
|
161 | 161 | .post > .metadata { |
|
162 | 162 | clear: left; |
|
163 | 163 | } |
|
164 | 164 | |
|
165 | 165 | .get { |
|
166 | 166 | font-weight: bold; |
|
167 | 167 | color: #d55; |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | * { |
|
171 | 171 | text-decoration: none; |
|
172 | 172 | } |
|
173 | 173 | |
|
174 | 174 | .dead_post { |
|
175 | 175 | background-color: #442222; |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | .quote { |
|
179 | 179 | color: greenyellow; |
|
180 | 180 | padding-left: 5px; |
|
181 | 181 | border-left: solid 2px greenyellow; |
|
182 | 182 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now