Skip to content

Commit b226cb4

Browse files
author
synapticloop
committed
file filtering for backslashes
1 parent 99f7ee7 commit b226cb4

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a name="documentr_top"></a>[![Build Status](https://travis-ci.org/synapticloop/documentr.svg?branch=master)](https://travis-ci.org/synapticloop/documentr) [![Download](https://api.bintray.com/packages/synapticloop/maven/documentr/images/download.svg)](https://bintray.com/synapticloop/maven/documentr/_latestVersion) [![GitHub Release](https://img.shields.io/github/release/synapticloop/documentr.svg)](https://github.com/synapticloop/documentr/releases) [![Gradle Plugin Release](https://img.shields.io/badge/gradle%20plugin-2.6.3-blue.svg)](https://plugins.gradle.org/plugin/synapticloop.documentr)
1+
<a name="documentr_top"></a>[![Build Status](https://travis-ci.org/synapticloop/documentr.svg?branch=master)](https://travis-ci.org/synapticloop/documentr) [![Download](https://api.bintray.com/packages/synapticloop/maven/documentr/images/download.svg)](https://bintray.com/synapticloop/maven/documentr/_latestVersion) [![GitHub Release](https://img.shields.io/github/release/synapticloop/documentr.svg)](https://github.com/synapticloop/documentr/releases) [![Gradle Plugin Release](https://img.shields.io/badge/gradle%20plugin-2.7.0-blue.svg)](https://plugins.gradle.org/plugin/synapticloop.documentr)
22

33
> **This project requires JVM version of at least 1.7**
44
@@ -234,7 +234,7 @@ This is a simple JSON file as show below:
234234
235235
{ "type":"inbuilt", "value":"jvm-compatability" },
236236
237-
{ "type": "markup", "value": "nn# Table of Contentsnn" },
237+
{ "type": "markup", "value": "\n\n# Table of Contents\n\n" },
238238
239239
{ "type": "toc", "value": "2" },
240240
{ "type": "toclinks", "value": "true" },
@@ -246,27 +246,27 @@ This is a simple JSON file as show below:
246246
247247
{ "type":"file", "value":"src/docs/pre-usage.md" },
248248
249-
{ "type": "markup", "value": "### The `documentr.json` filenn" },
250-
{ "type": "markup", "value": "This is a simple JSON file as show below:nn" },
251-
{ "type": "markup", "value":"n```n" },
249+
{ "type": "markup", "value": "### The `documentr.json` file\n\n" },
250+
{ "type": "markup", "value": "This is a simple JSON file as show below:\n\n" },
251+
{ "type": "markup", "value":"\n```\n" },
252252
253253
254254
{ "type": "file", "value":"documentr.json" },
255255
256256
257-
{ "type": "markup", "value":"n```n" },
258-
{ "type": "markup", "value":"> *in fact - the above file is included from the file system `documentr.json`, so that it is always up-to-date with the correct information...*nn" },
257+
{ "type": "markup", "value":"\n```\n" },
258+
{ "type": "markup", "value":"> *in fact - the above file is included from the file system `documentr.json`, so that it is always up-to-date with the correct information...*\n\n" },
259259
260260
{ "type":"template", "value":"src/docs/post-usage.md.templar" },
261261
262-
{ "type":"markup", "value":"nn```n" },
262+
{ "type":"markup", "value":"\n\n```\n" },
263263
264264
265265
{ "type":"file", "value":"src/main/resources/USAGE.txt" },
266266
{ "type":"file", "value":"src/main/resources/HELP.txt" },
267267
268268
269-
{ "type":"markup", "value":"n```n" },
269+
{ "type":"markup", "value":"\n```\n" },
270270
271271
{ "type": "file", "value":"src/docs/table-of-contents.md" },
272272
@@ -324,7 +324,7 @@ buildscript {
324324
}
325325
}
326326
dependencies {
327-
classpath "gradle.plugin.synapticloop:documentr:2.6.3"
327+
classpath "gradle.plugin.synapticloop:documentr:2.7.0"
328328
}
329329
}
330330
@@ -339,7 +339,7 @@ apply plugin: "synapticloop.documentr"
339339

340340
```
341341
plugins {
342-
id 'synapticloop.documentr' version '2.6.3'
342+
id 'synapticloop.documentr' version '2.7.0'
343343
}
344344
```
345345

@@ -376,7 +376,7 @@ simply run
376376

377377

378378
```
379-
java -jar documentr-2.6.3-all.jar
379+
java -jar documentr-2.7.0-all.jar
380380
```
381381

382382

@@ -392,7 +392,7 @@ Running:
392392

393393

394394
```
395-
java -jar documentr-2.6.3-all.jar --help
395+
java -jar documentr-2.7.0-all.jar --help
396396
```
397397

398398

@@ -462,7 +462,7 @@ be one of the following:
462462
{dumpcontext} - which dumps all available context key/value pairs to
463463
the output
464464
- file - the file will be included as is with no parsing done on it
465-
- markup - any valid markdown, with 'n' being replaced with a new line
465+
- markup - any valid markdown, with '\n' being replaced with a new line
466466
character. No templar parsing is done on this.
467467
- markdown - an alias for markup
468468
- inbuilt - one of the in-built templates (see below for a list of the
@@ -533,11 +533,11 @@ simply by entering the following line into you `documentr.json` file:
533533

534534

535535
```
536-
{ "type": "markup", "value": "\n\n# Table of Contents\n\n" },
536+
{ "type": "markup", "value": "\\n\\n# Table of Contents\\n\\n" },
537537
538538
{ "type": "toc", "value": "2" },
539539
{ "type": "toclinks", "value": "true" },
540-
{ "type": "toplink", "value": " <a name="documentr_top"></a>" },
540+
{ "type": "toplink", "value": " <a name=\"documentr_top\"></a>" },
541541
{ "type": "tocbacktotop", "value": " <sup><sup>[top](#documentr_top)</sup></sup>" },
542542
```
543543

@@ -561,7 +561,7 @@ contents for headers up to level `h6`.
561561
### `{ "type": "toplink" }`
562562

563563
This is the anchor name to go back to the top of the README file (rather than
564-
the top of the page. By default this is always set to `<a name=\"#documentr_top\"></a>`
564+
the top of the page. By default this is always set to `<a name=\\"#documentr_top\\"></a>`
565565
if you wish to change the `tocbacktotop`, then you will need to change this as
566566
well.
567567

@@ -825,9 +825,9 @@ repositories {
825825

826826
```
827827
dependencies {
828-
runtime(group: 'synapticloop', name: 'documentr', version: '2.6.3', ext: 'jar')
828+
runtime(group: 'synapticloop', name: 'documentr', version: '2.7.0', ext: 'jar')
829829
830-
compile(group: 'synapticloop', name: 'documentr', version: '2.6.3', ext: 'jar')
830+
compile(group: 'synapticloop', name: 'documentr', version: '2.7.0', ext: 'jar')
831831
}
832832
```
833833

@@ -839,9 +839,9 @@ or, more simply for versions of gradle greater than 2.1
839839

840840
```
841841
dependencies {
842-
runtime 'synapticloop:documentr:2.6.3'
842+
runtime 'synapticloop:documentr:2.7.0'
843843
844-
compile 'synapticloop:documentr:2.6.3'
844+
compile 'synapticloop:documentr:2.7.0'
845845
}
846846
```
847847

@@ -859,7 +859,7 @@ dependencies {
859859
<dependency>
860860
<groupId>synapticloop</groupId>
861861
<artifactId>documentr</artifactId>
862-
<version>2.6.3</version>
862+
<version>2.7.0</version>
863863
<type>jar</type>
864864
</dependency>
865865
```
@@ -924,7 +924,7 @@ This should appear in the artefact repository along with the compiled code, as a
924924

925925
For example:
926926

927-
`documentr-2.6.3.jar -> documentr-2.6.3-all.jar`
927+
`documentr-2.7.0.jar -> documentr-2.7.0-all.jar`
928928

929929

930930

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313
}
1414

1515
dependencies {
16-
classpath 'synapticloop:documentr:2.6.3'
16+
classpath 'synapticloop:documentr:2.7.0'
1717
}
1818
}
1919

@@ -37,7 +37,7 @@ group = 'synapticloop'
3737
archivesBaseName = 'documentr'
3838
description = """documentation (README) generator for projects in both markdown and asciidoc - this utilises the templar templating language - including generation of table of contents"""
3939

40-
version = '2.6.3'
40+
version = '2.7.0'
4141

4242
sourceCompatibility = 1.7
4343
targetCompatibility = 1.7

src/main/java/synapticloop/documentr/generator/Generator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public class Generator {
7474

7575
private static final String KEY_VALUE = "value";
7676
private static final String KEY_TYPE = "type";
77+
private static final String KEY_CONTEXT = "context";
7778

7879
private static final int TYPE_FILE = 1;
7980
private static final int TYPE_INBUILT = 0;
@@ -225,7 +226,7 @@ public void generate() throws DocumentrException {
225226
switch(TYPE_LOOKUP.get(type)) {
226227
case TYPE_FILE:
227228
stringBuilder.append("{pre\n");
228-
stringBuilder.append(FileUtils.readFileToString(new File(pathname)));
229+
stringBuilder.append(FileUtils.readFileToString(new File(pathname)).replace("\\", "\\\\"));
229230
stringBuilder.append("\npre}\n");
230231
break;
231232
case TYPE_MARKUP:
@@ -502,7 +503,7 @@ private String getInbuiltTemplateName(String template) {
502503
* @param jsonObject the json object that contains the context items
503504
*/
504505
private void overrideContext(TemplarContext templarContext, JSONObject jsonObject) {
505-
JSONObject contextObject = jsonObject.getJSONObject("context");
506+
JSONObject contextObject = jsonObject.getJSONObject(KEY_CONTEXT);
506507
if(null != contextObject) {
507508
Iterator<String> keys = contextObject.keys();
508509
while (keys.hasNext()) {

0 commit comments

Comments
 (0)