pagedown-rails 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b3cb60c629602193ace07a5bd76467dd3d1fc34
4
+ data.tar.gz: 4a638f41275592c27ceda75c521f87f815ec9587
5
+ SHA512:
6
+ metadata.gz: 2379e9fd8303f70d2bf36ac3e980e5619a7609ca6ee71063a55cc1e489dd60e9e1f1d4b9a7b52d092414bc1f14a209d9abf720cf857c3dca51a4bfdc13bf538a
7
+ data.tar.gz: e42154bae5d6475beab025886bea68b14aba4eef54e351dfe08d56268f20f6a14d26794f583491adbf6085c5b338b84710dd4f3a0f6c620e8e5012d7d527d511
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add this line to the assets group in your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'pagedown-rails', '~> 1.1.1'
10
+ gem 'pagedown-rails', '~> 1.1.2'
11
11
  ```
12
12
 
13
13
  Add the necessary libraries to `app/assets/javascripts/application.js`:
@@ -1,5 +1,5 @@
1
1
  module PageDown
2
2
  module Rails
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ if (typeof exports === "object" && typeof require === "function") // we're in a
4
4
  Markdown = exports;
5
5
  else
6
6
  Markdown = {};
7
-
7
+
8
8
  // The following text is included for historical reasons, but should
9
9
  // be taken with a pinch of salt; it's not all true anymore.
10
10
 
@@ -67,7 +67,11 @@ else
67
67
  if (original === identity)
68
68
  this[hookname] = func;
69
69
  else
70
- this[hookname] = function (x) { return func(original(x)); }
70
+ this[hookname] = function (text) {
71
+ var args = Array.prototype.slice.call(arguments, 0);
72
+ args[0] = original.apply(null, args);
73
+ return func.apply(null, args);
74
+ };
71
75
  },
72
76
  set: function (hookname, func) {
73
77
  if (!this[hookname])
@@ -103,9 +107,28 @@ else
103
107
 
104
108
  Markdown.Converter = function () {
105
109
  var pluginHooks = this.hooks = new HookCollection();
106
- pluginHooks.addNoop("plainLinkText"); // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link
107
- pluginHooks.addNoop("preConversion"); // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked
108
- pluginHooks.addNoop("postConversion"); // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml
110
+
111
+ // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link
112
+ pluginHooks.addNoop("plainLinkText");
113
+
114
+ // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked
115
+ pluginHooks.addNoop("preConversion");
116
+
117
+ // called with the text once all normalizations have been completed (tabs to spaces, line endings, etc.), but before any conversions have
118
+ pluginHooks.addNoop("postNormalization");
119
+
120
+ // Called with the text before / after creating block elements like code blocks and lists. Note that this is called recursively
121
+ // with inner content, e.g. it's called with the full text, and then only with the content of a blockquote. The inner
122
+ // call will receive outdented text.
123
+ pluginHooks.addNoop("preBlockGamut");
124
+ pluginHooks.addNoop("postBlockGamut");
125
+
126
+ // called with the text of a single block element before / after the span-level conversions (bold, code spans, etc.) have been made
127
+ pluginHooks.addNoop("preSpanGamut");
128
+ pluginHooks.addNoop("postSpanGamut");
129
+
130
+ // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml
131
+ pluginHooks.addNoop("postConversion");
109
132
 
110
133
  //
111
134
  // Private state of the converter instance:
@@ -133,7 +156,7 @@ else
133
156
  // Don't do that.
134
157
  if (g_urls)
135
158
  throw new Error("Recursive call to converter.makeHtml");
136
-
159
+
137
160
  // Create the private state objects.
138
161
  g_urls = new SaveHash();
139
162
  g_titles = new SaveHash();
@@ -169,6 +192,8 @@ else
169
192
  // contorted like /[ \t]*\n+/ .
170
193
  text = text.replace(/^[ \t]+$/mg, "");
171
194
 
195
+ text = pluginHooks.postNormalization(text);
196
+
172
197
  // Turn block-level HTML blocks into hash entries
173
198
  text = _HashHTMLBlocks(text);
174
199
 
@@ -305,7 +330,7 @@ else
305
330
  text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm, hashElement);
306
331
 
307
332
  // Special case just for <hr />. It was easier to make a special case than
308
- // to make the other regex more complicated.
333
+ // to make the other regex more complicated.
309
334
 
310
335
  /*
311
336
  text = text.replace(/
@@ -379,11 +404,16 @@ else
379
404
  return blockText;
380
405
  }
381
406
 
407
+ var blockGamutHookCallback = function (t) { return _RunBlockGamut(t); }
408
+
382
409
  function _RunBlockGamut(text, doNotUnhash) {
383
410
  //
384
411
  // These are all the transformations that form block-level
385
412
  // tags like paragraphs, headers, and list items.
386
413
  //
414
+
415
+ text = pluginHooks.preBlockGamut(text, blockGamutHookCallback);
416
+
387
417
  text = _DoHeaders(text);
388
418
 
389
419
  // Do Horizontal Rules:
@@ -396,6 +426,8 @@ else
396
426
  text = _DoCodeBlocks(text);
397
427
  text = _DoBlockQuotes(text);
398
428
 
429
+ text = pluginHooks.postBlockGamut(text, blockGamutHookCallback);
430
+
399
431
  // We already ran _HashHTMLBlocks() before, in Markdown(), but that
400
432
  // was to escape raw HTML in the original Markdown source. This time,
401
433
  // we're escaping the markup we've just created, so that we don't wrap
@@ -412,6 +444,8 @@ else
412
444
  // tags like paragraphs, headers, and list items.
413
445
  //
414
446
 
447
+ text = pluginHooks.preSpanGamut(text);
448
+
415
449
  text = _DoCodeSpans(text);
416
450
  text = _EscapeSpecialCharsWithinTagAttributes(text);
417
451
  text = _EncodeBackslashEscapes(text);
@@ -425,15 +459,17 @@ else
425
459
  // Must come after _DoAnchors(), because you can use < and >
426
460
  // delimiters in inline links like [this](<url>).
427
461
  text = _DoAutoLinks(text);
428
-
462
+
429
463
  text = text.replace(/~P/g, "://"); // put in place to prevent autolinking; reset now
430
-
464
+
431
465
  text = _EncodeAmpsAndAngles(text);
432
466
  text = _DoItalicsAndBold(text);
433
467
 
434
468
  // Do hard breaks:
435
469
  text = text.replace(/ +\n/g, " <br>\n");
436
470
 
471
+ text = pluginHooks.postSpanGamut(text);
472
+
437
473
  return text;
438
474
  }
439
475
 
@@ -443,7 +479,7 @@ else
443
479
  // don't conflict with their use in Markdown for code, italics and strong.
444
480
  //
445
481
 
446
- // Build a regex to find HTML tags and comments. See Friedl's
482
+ // Build a regex to find HTML tags and comments. See Friedl's
447
483
  // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
448
484
 
449
485
  // SE: changed the comment part of the regex
@@ -517,7 +553,7 @@ else
517
553
  |
518
554
  [^()\s]
519
555
  )*?
520
- )>?
556
+ )>?
521
557
  [ \t]*
522
558
  ( // $5
523
559
  (['"]) // quote char = $6
@@ -656,7 +692,7 @@ else
656
692
 
657
693
  return text;
658
694
  }
659
-
695
+
660
696
  function attributeEncode(text) {
661
697
  // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title)
662
698
  // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it)
@@ -689,7 +725,7 @@ else
689
725
  return whole_match;
690
726
  }
691
727
  }
692
-
728
+
693
729
  alt_text = escapeCharacters(attributeEncode(alt_text), "*_[]()");
694
730
  url = escapeCharacters(url, "*_");
695
731
  var result = "<img src=\"" + url + "\" alt=\"" + alt_text + "\"";
@@ -713,7 +749,7 @@ else
713
749
  // Setext-style headers:
714
750
  // Header 1
715
751
  // ========
716
- //
752
+ //
717
753
  // Header 2
718
754
  // --------
719
755
  //
@@ -872,7 +908,7 @@ else
872
908
  //
873
909
  // We changed this to behave identical to MarkdownSharp. This is the constructed RegEx,
874
910
  // with {MARKER} being one of \d+[.] or [*+-], depending on list_type:
875
-
911
+
876
912
  /*
877
913
  list_str = list_str.replace(/
878
914
  (^[ \t]*) // leading whitespace = $1
@@ -920,7 +956,7 @@ else
920
956
  function _DoCodeBlocks(text) {
921
957
  //
922
958
  // Process Markdown `<pre><code>` blocks.
923
- //
959
+ //
924
960
 
925
961
  /*
926
962
  text = text.replace(/
@@ -938,7 +974,7 @@ else
938
974
  // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
939
975
  text += "~0";
940
976
 
941
- text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
977
+ text = text.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
942
978
  function (wholeMatch, m1, m2) {
943
979
  var codeblock = m1;
944
980
  var nextChar = m2;
@@ -968,26 +1004,26 @@ else
968
1004
  function _DoCodeSpans(text) {
969
1005
  //
970
1006
  // * Backtick quotes are used for <code></code> spans.
971
- //
1007
+ //
972
1008
  // * You can use multiple backticks as the delimiters if you want to
973
1009
  // include literal backticks in the code span. So, this input:
974
- //
1010
+ //
975
1011
  // Just type ``foo `bar` baz`` at the prompt.
976
- //
1012
+ //
977
1013
  // Will translate to:
978
- //
1014
+ //
979
1015
  // <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
980
- //
1016
+ //
981
1017
  // There's no arbitrary limit to the number of backticks you
982
1018
  // can use as delimters. If you need three consecutive backticks
983
1019
  // in your code, use four for delimiters, etc.
984
1020
  //
985
1021
  // * You can use spaces to get literal backticks at the edges:
986
- //
1022
+ //
987
1023
  // ... type `` `bar` `` ...
988
- //
1024
+ //
989
1025
  // Turns to:
990
- //
1026
+ //
991
1027
  // ... type <code>`bar`</code> ...
992
1028
  //
993
1029
 
@@ -1120,7 +1156,7 @@ else
1120
1156
 
1121
1157
  var grafs = text.split(/\n{2,}/g);
1122
1158
  var grafsOut = [];
1123
-
1159
+
1124
1160
  var markerRe = /~K(\d+)K/;
1125
1161
 
1126
1162
  //
@@ -1169,7 +1205,7 @@ else
1169
1205
  text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&amp;");
1170
1206
 
1171
1207
  // Encode naked <'s
1172
- text = text.replace(/<(?![a-z\/?\$!])/gi, "&lt;");
1208
+ text = text.replace(/<(?![a-z\/?!]|~D)/gi, "&lt;");
1173
1209
 
1174
1210
  return text;
1175
1211
  }
@@ -1195,17 +1231,49 @@ else
1195
1231
  return text;
1196
1232
  }
1197
1233
 
1234
+ function handleTrailingParens(wholeMatch, lookbehind, protocol, link) {
1235
+ if (lookbehind)
1236
+ return wholeMatch;
1237
+ if (link.charAt(link.length - 1) !== ")")
1238
+ return "<" + protocol + link + ">";
1239
+ var parens = link.match(/[()]/g);
1240
+ var level = 0;
1241
+ for (var i = 0; i < parens.length; i++) {
1242
+ if (parens[i] === "(") {
1243
+ if (level <= 0)
1244
+ level = 1;
1245
+ else
1246
+ level++;
1247
+ }
1248
+ else {
1249
+ level--;
1250
+ }
1251
+ }
1252
+ var tail = "";
1253
+ if (level < 0) {
1254
+ var re = new RegExp("\\){1," + (-level) + "}$");
1255
+ link = link.replace(re, function (trailingParens) {
1256
+ tail = trailingParens;
1257
+ return "";
1258
+ });
1259
+ }
1260
+
1261
+ return "<" + protocol + link + ">" + tail;
1262
+ }
1263
+
1198
1264
  function _DoAutoLinks(text) {
1199
1265
 
1200
1266
  // note that at this point, all other URL in the text are already hyperlinked as <a href=""></a>
1201
1267
  // *except* for the <http://www.foo.com> case
1202
1268
 
1203
1269
  // automatically add < and > around unadorned raw hyperlinks
1204
- // must be preceded by space/BOF and followed by non-word/EOF character
1205
- text = text.replace(/(^|\s)(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\]])($|\W)/gi, "$1<$2$3>$4");
1270
+ // must be preceded by a non-word character (and not by =" or <) and followed by non-word/EOF character
1271
+ // simulating the lookbehind in a consuming way is okay here, since a URL can neither and with a " nor
1272
+ // with a <, so there is no risk of overlapping matches.
1273
+ text = text.replace(/(="|<)?\b(https?|ftp)(:\/\/[-A-Z0-9+&@#\/%?=~_|\[\]\(\)!:,\.;]*[-A-Z0-9+&@#\/%=~_|\[\])])(?=$|\W)/gi, handleTrailingParens);
1206
1274
 
1207
1275
  // autolink anything like <http://example.com>
1208
-
1276
+
1209
1277
  var replacer = function (wholematch, m1) { return "<a href=\"" + m1 + "\">" + pluginHooks.plainLinkText(m1) + "</a>"; }
1210
1278
  text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer);
1211
1279
 
@@ -1287,7 +1355,7 @@ else
1287
1355
 
1288
1356
  var _problemUrlChars = /(?:["'*()[\]:]|~D)/g;
1289
1357
 
1290
- // hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems
1358
+ // hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems
1291
1359
  function encodeProblemUrlChars(url) {
1292
1360
  if (!url)
1293
1361
  return "";
@@ -17,39 +17,90 @@
17
17
  isOpera: /opera/.test(nav.userAgent.toLowerCase())
18
18
  };
19
19
 
20
+ var defaultsStrings = {
21
+ bold: "Strong <strong> Ctrl+B",
22
+ boldexample: "strong text",
23
+
24
+ italic: "Emphasis <em> Ctrl+I",
25
+ italicexample: "emphasized text",
26
+
27
+ link: "Hyperlink <a> Ctrl+L",
28
+ linkdescription: "enter link description here",
29
+ linkdialog: "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>",
30
+
31
+ quote: "Blockquote <blockquote> Ctrl+Q",
32
+ quoteexample: "Blockquote",
33
+
34
+ code: "Code Sample <pre><code> Ctrl+K",
35
+ codeexample: "enter code here",
36
+
37
+ image: "Image <img> Ctrl+G",
38
+ imagedescription: "enter image description here",
39
+ imagedialog: "<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>",
40
+
41
+ olist: "Numbered List <ol> Ctrl+O",
42
+ ulist: "Bulleted List <ul> Ctrl+U",
43
+ litem: "List item",
44
+
45
+ heading: "Heading <h1>/<h2> Ctrl+H",
46
+ headingexample: "Heading",
47
+
48
+ hr: "Horizontal Rule <hr> Ctrl+R",
49
+
50
+ undo: "Undo - Ctrl+Z",
51
+ redo: "Redo - Ctrl+Y",
52
+ redomac: "Redo - Ctrl+Shift+Z",
53
+
54
+ help: "Markdown Editing Help"
55
+ };
56
+
20
57
 
21
58
  // -------------------------------------------------------------------
22
59
  // YOUR CHANGES GO HERE
23
60
  //
24
- // I've tried to localize the things you are likely to change to
61
+ // I've tried to localize the things you are likely to change to
25
62
  // this area.
26
63
  // -------------------------------------------------------------------
27
64
 
28
- // The text that appears on the upper part of the dialog box when
29
- // entering links.
30
- var linkDialogText = "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>";
31
- var imageDialogText = "<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>";
32
-
33
65
  // The default text that appears in the dialog input box when entering
34
66
  // links.
35
67
  var imageDefaultText = "http://";
36
68
  var linkDefaultText = "http://";
37
69
 
38
- var defaultHelpHoverTitle = "Markdown Editing Help";
39
-
40
70
  // -------------------------------------------------------------------
41
71
  // END OF YOUR CHANGES
42
72
  // -------------------------------------------------------------------
43
73
 
44
- // help, if given, should have a property "handler", the click handler for the help button,
45
- // and can have an optional property "title" for the button's tooltip (defaults to "Markdown Editing Help").
46
- // If help isn't given, not help button is created.
74
+ // options, if given, can have the following properties:
75
+ // options.helpButton = { handler: yourEventHandler }
76
+ // options.strings = { italicexample: "slanted text" }
77
+ // `yourEventHandler` is the click handler for the help button.
78
+ // If `options.helpButton` isn't given, not help button is created.
79
+ // `options.strings` can have any or all of the same properties as
80
+ // `defaultStrings` above, so you can just override some string displayed
81
+ // to the user on a case-by-case basis, or translate all strings to
82
+ // a different language.
83
+ //
84
+ // For backwards compatibility reasons, the `options` argument can also
85
+ // be just the `helpButton` object, and `strings.help` can also be set via
86
+ // `helpButton.title`. This should be considered legacy.
47
87
  //
48
88
  // The constructed editor object has the methods:
49
89
  // - getConverter() returns the markdown converter object that was passed to the constructor
50
90
  // - run() actually starts the editor; should be called after all necessary plugins are registered. Calling this more than once is a no-op.
51
91
  // - refreshPreview() forces the preview to be updated. This method is only available after run() was called.
52
- Markdown.Editor = function (markdownConverter, idPostfix, help) {
92
+ Markdown.Editor = function (markdownConverter, idPostfix, options) {
93
+
94
+ options = options || {};
95
+
96
+ if (typeof options.handler === "function") { //backwards compatible behavior
97
+ options = { helpButton: options };
98
+ }
99
+ options.strings = options.strings || {};
100
+ if (options.helpButton) {
101
+ options.strings.help = options.strings.help || options.helpButton.title;
102
+ }
103
+ var getString = function (identifier) { return options.strings[identifier] || defaultsStrings[identifier]; }
53
104
 
54
105
  idPostfix = idPostfix || "";
55
106
 
@@ -71,7 +122,7 @@
71
122
  return; // already initialized
72
123
 
73
124
  panels = new PanelCollection(idPostfix);
74
- var commandManager = new CommandManager(hooks);
125
+ var commandManager = new CommandManager(hooks, getString);
75
126
  var previewManager = new PreviewManager(markdownConverter, panels, function () { hooks.onPreviewRefresh(); });
76
127
  var undoManager, uiManager;
77
128
 
@@ -88,7 +139,7 @@
88
139
  }
89
140
  }
90
141
 
91
- uiManager = new UIManager(idPostfix, panels, undoManager, previewManager, commandManager, help);
142
+ uiManager = new UIManager(idPostfix, panels, undoManager, previewManager, commandManager, options.helpButton, getString);
92
143
  uiManager.setUndoRedoButtonStates();
93
144
 
94
145
  var forceRefresh = that.refreshPreview = function () { previewManager.refresh(true); };
@@ -160,7 +211,7 @@
160
211
  beforeReplacer = function (s) { that.before += s; return ""; }
161
212
  afterReplacer = function (s) { that.after = s + that.after; return ""; }
162
213
  }
163
-
214
+
164
215
  this.selection = this.selection.replace(/^(\s*)/, beforeReplacer).replace(/(\s*)$/, afterReplacer);
165
216
  };
166
217
 
@@ -228,14 +279,14 @@
228
279
  }
229
280
  };
230
281
 
231
- // end of Chunks
282
+ // end of Chunks
232
283
 
233
284
  // A collection of the important regions on the page.
234
285
  // Cached so we don't have to keep traversing the DOM.
235
286
  // Also holds ieCachedRange and ieCachedScrollTop, where necessary; working around
236
287
  // this issue:
237
288
  // Internet explorer has problems with CSS sprite buttons that use HTML
238
- // lists. When you click on the background image "button", IE will
289
+ // lists. When you click on the background image "button", IE will
239
290
  // select the non-existent link text and discard the selection in the
240
291
  // textarea. The solution to this is to cache the textarea selection
241
292
  // on the button's mousedown event and set a flag. In the part of the
@@ -249,7 +300,7 @@
249
300
  function PanelCollection(postfix) {
250
301
  this.buttonBar = doc.getElementById("wmd-button-bar" + postfix);
251
302
  this.preview = doc.getElementById("wmd-preview" + postfix);
252
- this.input = doc.getElementsByClassName("wmd-input" + postfix)[0];
303
+ this.input = doc.getElementById("wmd-input" + postfix);
253
304
  };
254
305
 
255
306
  // Returns true if the DOM element is visible, false if it's hidden.
@@ -517,13 +568,13 @@
517
568
 
518
569
  var handled = false;
519
570
 
520
- if (event.ctrlKey || event.metaKey) {
571
+ if ((event.ctrlKey || event.metaKey) && !event.altKey) {
521
572
 
522
573
  // IE and Opera do not support charCode.
523
574
  var keyCode = event.charCode || event.keyCode;
524
575
  var keyCodeChar = String.fromCharCode(keyCode);
525
576
 
526
- switch (keyCodeChar) {
577
+ switch (keyCodeChar.toLowerCase()) {
527
578
 
528
579
  case "y":
529
580
  undoObj.redo();
@@ -580,7 +631,7 @@
580
631
  setMode("escape");
581
632
  }
582
633
  else if ((keyCode < 16 || keyCode > 20) && keyCode != 91) {
583
- // 16-20 are shift, etc.
634
+ // 16-20 are shift, etc.
584
635
  // 91: left window key
585
636
  // I think this might be a little messed up since there are
586
637
  // a lot of nonprinting keys above 20.
@@ -593,7 +644,7 @@
593
644
  util.addEvent(panels.input, "keypress", function (event) {
594
645
  // keyCode 89: y
595
646
  // keyCode 90: z
596
- if ((event.ctrlKey || event.metaKey) && (event.keyCode == 89 || event.keyCode == 90)) {
647
+ if ((event.ctrlKey || event.metaKey) && !event.altKey && (event.keyCode == 89 || event.keyCode == 90)) {
597
648
  event.preventDefault();
598
649
  }
599
650
  });
@@ -724,7 +775,7 @@
724
775
 
725
776
  if (panels.ieCachedRange)
726
777
  stateObj.scrollTop = panels.ieCachedScrollTop; // this is set alongside with ieCachedRange
727
-
778
+
728
779
  panels.ieCachedRange = null;
729
780
 
730
781
  this.setInputAreaSelection();
@@ -972,9 +1023,9 @@
972
1023
 
973
1024
  var background = doc.createElement("div"),
974
1025
  style = background.style;
975
-
1026
+
976
1027
  background.className = "wmd-prompt-background";
977
-
1028
+
978
1029
  style.position = "absolute";
979
1030
  style.top = "0";
980
1031
 
@@ -1161,7 +1212,7 @@
1161
1212
  }, 0);
1162
1213
  };
1163
1214
 
1164
- function UIManager(postfix, panels, undoManager, previewManager, commandManager, helpOptions) {
1215
+ function UIManager(postfix, panels, undoManager, previewManager, commandManager, helpOptions, getString) {
1165
1216
 
1166
1217
  var inputBox = panels.input,
1167
1218
  buttons = {}; // buttons.undo, buttons.link, etc. The actual DOM elements.
@@ -1289,7 +1340,7 @@
1289
1340
  //
1290
1341
  // var link = CreateLinkDialog();
1291
1342
  // makeMarkdownLink(link);
1292
- //
1343
+ //
1293
1344
  // Instead of this straightforward method of handling a
1294
1345
  // dialog I have to pass any code which would execute
1295
1346
  // after the dialog is dismissed (e.g. link creation)
@@ -1411,33 +1462,33 @@
1411
1462
  xPosition += 25;
1412
1463
  }
1413
1464
 
1414
- buttons.bold = makeButton("wmd-bold-button", "Strong <strong> Ctrl+B", "0px", bindCommand("doBold"));
1415
- buttons.italic = makeButton("wmd-italic-button", "Emphasis <em> Ctrl+I", "-20px", bindCommand("doItalic"));
1465
+ buttons.bold = makeButton("wmd-bold-button", getString("bold"), "0px", bindCommand("doBold"));
1466
+ buttons.italic = makeButton("wmd-italic-button", getString("italic"), "-20px", bindCommand("doItalic"));
1416
1467
  makeSpacer(1);
1417
- buttons.link = makeButton("wmd-link-button", "Hyperlink <a> Ctrl+L", "-40px", bindCommand(function (chunk, postProcessing) {
1468
+ buttons.link = makeButton("wmd-link-button", getString("link"), "-40px", bindCommand(function (chunk, postProcessing) {
1418
1469
  return this.doLinkOrImage(chunk, postProcessing, false);
1419
1470
  }));
1420
- buttons.quote = makeButton("wmd-quote-button", "Blockquote <blockquote> Ctrl+Q", "-60px", bindCommand("doBlockquote"));
1421
- buttons.code = makeButton("wmd-code-button", "Code Sample <pre><code> Ctrl+K", "-80px", bindCommand("doCode"));
1422
- buttons.image = makeButton("wmd-image-button", "Image <img> Ctrl+G", "-100px", bindCommand(function (chunk, postProcessing) {
1471
+ buttons.quote = makeButton("wmd-quote-button", getString("quote"), "-60px", bindCommand("doBlockquote"));
1472
+ buttons.code = makeButton("wmd-code-button", getString("code"), "-80px", bindCommand("doCode"));
1473
+ buttons.image = makeButton("wmd-image-button", getString("image"), "-100px", bindCommand(function (chunk, postProcessing) {
1423
1474
  return this.doLinkOrImage(chunk, postProcessing, true);
1424
1475
  }));
1425
1476
  makeSpacer(2);
1426
- buttons.olist = makeButton("wmd-olist-button", "Numbered List <ol> Ctrl+O", "-120px", bindCommand(function (chunk, postProcessing) {
1477
+ buttons.olist = makeButton("wmd-olist-button", getString("olist"), "-120px", bindCommand(function (chunk, postProcessing) {
1427
1478
  this.doList(chunk, postProcessing, true);
1428
1479
  }));
1429
- buttons.ulist = makeButton("wmd-ulist-button", "Bulleted List <ul> Ctrl+U", "-140px", bindCommand(function (chunk, postProcessing) {
1480
+ buttons.ulist = makeButton("wmd-ulist-button", getString("ulist"), "-140px", bindCommand(function (chunk, postProcessing) {
1430
1481
  this.doList(chunk, postProcessing, false);
1431
1482
  }));
1432
- buttons.heading = makeButton("wmd-heading-button", "Heading <h1>/<h2> Ctrl+H", "-160px", bindCommand("doHeading"));
1433
- buttons.hr = makeButton("wmd-hr-button", "Horizontal Rule <hr> Ctrl+R", "-180px", bindCommand("doHorizontalRule"));
1483
+ buttons.heading = makeButton("wmd-heading-button", getString("heading"), "-160px", bindCommand("doHeading"));
1484
+ buttons.hr = makeButton("wmd-hr-button", getString("hr"), "-180px", bindCommand("doHorizontalRule"));
1434
1485
  makeSpacer(3);
1435
- buttons.undo = makeButton("wmd-undo-button", "Undo - Ctrl+Z", "-200px", null);
1486
+ buttons.undo = makeButton("wmd-undo-button", getString("undo"), "-200px", null);
1436
1487
  buttons.undo.execute = function (manager) { if (manager) manager.undo(); };
1437
1488
 
1438
1489
  var redoTitle = /win/.test(nav.platform.toLowerCase()) ?
1439
- "Redo - Ctrl+Y" :
1440
- "Redo - Ctrl+Shift+Z"; // mac and other non-Windows platforms
1490
+ getString("redo") :
1491
+ getString("redomac"); // mac and other non-Windows platforms
1441
1492
 
1442
1493
  buttons.redo = makeButton("wmd-redo-button", redoTitle, "-220px", null);
1443
1494
  buttons.redo.execute = function (manager) { if (manager) manager.redo(); };
@@ -1451,7 +1502,7 @@
1451
1502
  helpButton.XShift = "-240px";
1452
1503
  helpButton.isHelp = true;
1453
1504
  helpButton.style.right = "0px";
1454
- helpButton.title = helpOptions.title || defaultHelpHoverTitle;
1505
+ helpButton.title = getString("help");
1455
1506
  helpButton.onclick = helpOptions.handler;
1456
1507
 
1457
1508
  setupButton(helpButton, true);
@@ -1473,8 +1524,9 @@
1473
1524
 
1474
1525
  }
1475
1526
 
1476
- function CommandManager(pluginHooks) {
1527
+ function CommandManager(pluginHooks, getString) {
1477
1528
  this.hooks = pluginHooks;
1529
+ this.getString = getString;
1478
1530
  }
1479
1531
 
1480
1532
  var commandProto = CommandManager.prototype;
@@ -1504,11 +1556,11 @@
1504
1556
  };
1505
1557
 
1506
1558
  commandProto.doBold = function (chunk, postProcessing) {
1507
- return this.doBorI(chunk, postProcessing, 2, "strong text");
1559
+ return this.doBorI(chunk, postProcessing, 2, this.getString("boldexample"));
1508
1560
  };
1509
1561
 
1510
1562
  commandProto.doItalic = function (chunk, postProcessing) {
1511
- return this.doBorI(chunk, postProcessing, 1, "emphasized text");
1563
+ return this.doBorI(chunk, postProcessing, 1, this.getString("italicexample"));
1512
1564
  };
1513
1565
 
1514
1566
  // chunk: The selected region that will be enclosed with */**
@@ -1664,7 +1716,7 @@
1664
1716
 
1665
1717
  }
1666
1718
  else {
1667
-
1719
+
1668
1720
  // We're moving start and end tag back into the selection, since (as we're in the else block) we're not
1669
1721
  // *removing* a link, but *adding* one, so whatever findTags() found is now back to being part of the
1670
1722
  // link text. linkEnteredCallback takes care of escaping any brackets.
@@ -1702,7 +1754,7 @@
1702
1754
  // would mean a zero-width match at the start. Since zero-width matches advance the string position,
1703
1755
  // the first bracket could then not act as the "not a backslash" for the second.
1704
1756
  chunk.selection = (" " + chunk.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g, "$1\\").substr(1);
1705
-
1757
+
1706
1758
  var linkDef = " [999]: " + properlyEncoded(link);
1707
1759
 
1708
1760
  var num = that.addLinkDef(chunk, linkDef);
@@ -1711,10 +1763,10 @@
1711
1763
 
1712
1764
  if (!chunk.selection) {
1713
1765
  if (isImage) {
1714
- chunk.selection = "enter image description here";
1766
+ chunk.selection = that.getString("imagedescription");
1715
1767
  }
1716
1768
  else {
1717
- chunk.selection = "enter link description here";
1769
+ chunk.selection = that.getString("linkdescription");
1718
1770
  }
1719
1771
  }
1720
1772
  }
@@ -1725,10 +1777,10 @@
1725
1777
 
1726
1778
  if (isImage) {
1727
1779
  if (!this.hooks.insertImageDialog(linkEnteredCallback))
1728
- ui.prompt(imageDialogText, imageDefaultText, linkEnteredCallback);
1780
+ ui.prompt(this.getString("imagedialog"), imageDefaultText, linkEnteredCallback);
1729
1781
  }
1730
1782
  else {
1731
- ui.prompt(linkDialogText, linkDefaultText, linkEnteredCallback);
1783
+ ui.prompt(this.getString("linkdialog"), linkDefaultText, linkEnteredCallback);
1732
1784
  }
1733
1785
  return true;
1734
1786
  }
@@ -1744,7 +1796,7 @@
1744
1796
  chunk.before = chunk.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/, "\n\n");
1745
1797
  chunk.before = chunk.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/, "\n\n");
1746
1798
  chunk.before = chunk.before.replace(/(\n|^)[ \t]+\n$/, "\n\n");
1747
-
1799
+
1748
1800
  // There's no selection, end the cursor wasn't at the end of the line:
1749
1801
  // The user wants to split the current list item / code line / blockquote line
1750
1802
  // (for the latter it doesn't really matter) in two. Temporarily select the
@@ -1772,7 +1824,7 @@
1772
1824
  commandMgr.doCode(chunk);
1773
1825
  }
1774
1826
  }
1775
-
1827
+
1776
1828
  if (fakeSelection) {
1777
1829
  chunk.after = chunk.selection + chunk.after;
1778
1830
  chunk.selection = "";
@@ -1795,7 +1847,7 @@
1795
1847
  });
1796
1848
 
1797
1849
  chunk.selection = chunk.selection.replace(/^(\s|>)+$/, "");
1798
- chunk.selection = chunk.selection || "Blockquote";
1850
+ chunk.selection = chunk.selection || this.getString("quoteexample");
1799
1851
 
1800
1852
  // The original code uses a regular expression to find out how much of the
1801
1853
  // text *directly before* the selection already was a blockquote:
@@ -1952,7 +2004,7 @@
1952
2004
 
1953
2005
  if (!chunk.selection) {
1954
2006
  chunk.startTag = " ";
1955
- chunk.selection = "enter code here";
2007
+ chunk.selection = this.getString("codeexample");
1956
2008
  }
1957
2009
  else {
1958
2010
  if (/^[ ]{0,3}\S/m.test(chunk.selection)) {
@@ -1962,7 +2014,7 @@
1962
2014
  chunk.before += " ";
1963
2015
  }
1964
2016
  else {
1965
- chunk.selection = chunk.selection.replace(/^[ ]{4}/gm, "");
2017
+ chunk.selection = chunk.selection.replace(/^(?:[ ]{4}|[ ]{0,3}\t)/gm, "");
1966
2018
  }
1967
2019
  }
1968
2020
  }
@@ -1975,7 +2027,7 @@
1975
2027
  if (!chunk.startTag && !chunk.endTag) {
1976
2028
  chunk.startTag = chunk.endTag = "`";
1977
2029
  if (!chunk.selection) {
1978
- chunk.selection = "enter code here";
2030
+ chunk.selection = this.getString("codeexample");
1979
2031
  }
1980
2032
  }
1981
2033
  else if (chunk.endTag && !chunk.startTag) {
@@ -2069,7 +2121,7 @@
2069
2121
  });
2070
2122
 
2071
2123
  if (!chunk.selection) {
2072
- chunk.selection = "List item";
2124
+ chunk.selection = this.getString("litem");
2073
2125
  }
2074
2126
 
2075
2127
  var prefix = getItemPrefix();
@@ -2101,7 +2153,7 @@
2101
2153
  // make a level 2 hash header around some default text.
2102
2154
  if (!chunk.selection) {
2103
2155
  chunk.startTag = "## ";
2104
- chunk.selection = "Heading";
2156
+ chunk.selection = this.getString("headingexample");
2105
2157
  chunk.endTag = " ##";
2106
2158
  return;
2107
2159
  }
@@ -2157,4 +2209,4 @@
2157
2209
  }
2158
2210
 
2159
2211
 
2160
- })();
2212
+ })();
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagedown-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
5
- prerelease:
4
+ version: 1.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Richard Hubers
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
11
+ date: 2013-03-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: railties
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -47,26 +44,25 @@ files:
47
44
  homepage: http://github.com/rh/pagedown-rails
48
45
  licenses:
49
46
  - MIT
47
+ metadata: {}
50
48
  post_install_message:
51
49
  rdoc_options: []
52
50
  require_paths:
53
51
  - lib
54
52
  required_ruby_version: !ruby/object:Gem::Requirement
55
- none: false
56
53
  requirements:
57
- - - ! '>='
54
+ - - '>='
58
55
  - !ruby/object:Gem::Version
59
56
  version: '0'
60
57
  required_rubygems_version: !ruby/object:Gem::Requirement
61
- none: false
62
58
  requirements:
63
- - - ! '>='
59
+ - - '>='
64
60
  - !ruby/object:Gem::Version
65
61
  version: '0'
66
62
  requirements: []
67
63
  rubyforge_project:
68
- rubygems_version: 1.8.23
64
+ rubygems_version: 2.0.3
69
65
  signing_key:
70
- specification_version: 3
66
+ specification_version: 4
71
67
  summary: This gem makes PageDown available in the Rails asset pipeline
72
68
  test_files: []