diff --git a/.github/ISSUE_TEMPLATE/dau-error.md b/.github/ISSUE_TEMPLATE/dau-error.md new file mode 100644 index 0000000..3cc5e58 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/dau-error.md @@ -0,0 +1,25 @@ +--- +name: DAU error +about: "Since this is both a DAU and Dizzy Rewrite repository, DAU troubleshooting also goes here." +title: "[GTC] Excerpt from..." +labels: Grammar/Typo Correction +assignees: MeowcaTheoRange + +--- + +## DAU parser command run + +` +node code/filer.js master Markdown +` + +## Terminal output + +``` +[me@computer Dizzy-Rewrite]$ node code/filer.js master Markdown +[me@computer Dizzy-Rewrite]$ +``` + +## Operating System + +Linux \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/grammar-typo-correction.md b/.github/ISSUE_TEMPLATE/grammar-typo-correction.md index a63088d..f3cb29d 100644 --- a/.github/ISSUE_TEMPLATE/grammar-typo-correction.md +++ b/.github/ISSUE_TEMPLATE/grammar-typo-correction.md @@ -12,7 +12,7 @@ assignees: MeowcaTheoRange You can use the GitHub browser or download as ZIP to locate the path --> -Dizzy-AU/**story/human-readable/...** +Dizzy-Rewrite/**format/source/...** ## Affected excerpt diff --git a/.gitignore b/.gitignore index f9d00a6..338e418 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -database.json \ No newline at end of file +database.json +/format/converted/ +/format/source/json/ \ No newline at end of file diff --git a/checklist.md b/checklist.md new file mode 100644 index 0000000..6e1334d --- /dev/null +++ b/checklist.md @@ -0,0 +1,21 @@ +[x] Create formatting guide + +[x] Create MD parser + +[x] Create README + +[] Create HTML parser (basic) + +[x] Create EJS/JSON parser (automatic) + +[x] Separate sentences by quotes (dialogue) and sent/recieved reciept formatting (messaging) + +[x] Publish to GitHub + +[] Finish rewriting the Dizzy AU story + +[x] Open-source DAU so other people can use it for their stories! + +[] Wattpad/AooO API? I'll have to check. Possible. + +[x] Support for multiple files + command arguments? \ No newline at end of file diff --git a/code/converter.js b/code/converter.js index 778b671..765345c 100644 --- a/code/converter.js +++ b/code/converter.js @@ -51,7 +51,49 @@ var DAUConverters = { x ).join("") + "\n\n"; else plctext = text + "\n\n"; - currentExport.data[i].data += plctext.replace(/(:\/)|(\/:)/gi, "*"); + currentExport.data[i].data += plctext + .replace(/((? { + currentExport.data[i] = { + data: "", + name: chapter.name + }; + currentExport.data[i].data += `${chapter.name}\n`; + if (chapter.info) { + currentExport.data[i].data += `\t`; + if (chapter.info.location) currentExport.data[i].data += `${chapter.info.location}`; + if (chapter.info.time) currentExport.data[i].data += `@${chapter.info.time}`; + if (chapter.info.time && chapter.info.location) currentExport.data[i].data += `\n`; + } + currentExport.data[i].data += `\n`; + currentExport.data[i].data += `Characters:\n`; + Object.entries(chapter.characters).forEach(([_, character]) => { + currentExport.data[i].data += `- ${character.name.join(" ")}\n`; + }); + chapter.characters["%"] = narrator; + chapter.dialogue.forEach((dialogue) => { + currentExport.data[i].data += `\n${chapter.characters[dialogue.speaker].name.join(" ")}\n`; + dialogue.dialogue.forEach((text) => { + var plctext; + if (Array.isArray(text)) + plctext = "\t" + text.join("") + "\n"; + else plctext = "\t" + text + "\n"; + currentExport.data[i].data += plctext + .replace(/((? 1) fs.mkdirSync(namefolder); var allFileData = convop.data.map(x=>x.data); - fs.writeFileSync(path.join(folder, name + convop.extension), allFileData.join("")); - convop.data.forEach((data) => { + fs.writeFileSync(path.join(folder, name + convop.extension), allFileData.join("")); + if (convop.data.length > 1) convop.data.forEach((data) => { fs.writeFileSync(path.join(namefolder, data.name.replace(/[/\\?%*:|"<> ]/g, '_') + convop.extension), data.data); }) - } TokenizeFiles(process.argv[2], process.argv[3]); \ No newline at end of file diff --git a/code/parser.js b/code/parser.js index 95ff8a8..df6dfdc 100644 --- a/code/parser.js +++ b/code/parser.js @@ -42,13 +42,13 @@ function DAUTokenizer(string) { var temp = (string.includes("\r\n") ? string.split("\r\n") : string.split("\n")); var linearray = []; temp.forEach((v) => { - if (/^\t*\S+/.test(v)) linearray.push(v.replace(/\s*$/, "")); + if (/^(\t|\s\s)*\S+/.test(v)) linearray.push(v.replace(/\s*$/, "")); }); for (line of linearray) { if (/^\? /.test(line)) { var ine = line.replace(/^\? /, "").split(" :: "); if (ine[1]) { - ine[1] = ine[1].split(" @ "); + ine[1] = ine[1].split("@"); ine[1] = {location: ine[1][0], time: ine[1][1]}; } TokenizerCtx.currentChapter = new Chapter(...ine); @@ -56,13 +56,13 @@ function DAUTokenizer(string) { } else if (/^\- /.test(line)) { var ine = line.replace(/^\- /, "").split(" :: "); TokenizerCtx.currentChapter.characters[ine[0]] = new Character(...ine); - } else if (/^(\t\t)|( )/.test(line)){ - var ine = line.replace(/^(\t\t)|( )/, ""); + } else if (/^(\t\t)|(\s\s\s\s)/.test(line)){ + var ine = line.replace(/^(\t\t)|(\s\s\s\s)/, ""); var sliced = sliceDialogue(ine); TokenizerCtx.currentDialogueBlock.dialogue.push(sliced); - } else if (/^(\t)|( )/.test(line)){ - var ine = line.replace(/^(\t)|( )/, ""); + } else if (/^(\t)|(\s\s)/.test(line)){ + var ine = line.replace(/^(\t)|(\s\s)/, ""); TokenizerCtx.currentDialogueBlock = new Dialogue(ine); TokenizerCtx.currentChapter.dialogue.push(TokenizerCtx.currentDialogueBlock); } diff --git a/format/converted/markdown/readme.md b/format/converted/markdown/readme.md index fddd284..af4863d 100644 --- a/format/converted/markdown/readme.md +++ b/format/converted/markdown/readme.md @@ -45,5 +45,5 @@ In fact, this README page you're reading was originally made in DAU. Don't belie Anyway, you're free to use DAU to start your fictonal endeavors today. Check out [the reuse guide](/format/converted/markdown/reuse.md) for more info. --- By the way, DAU is licensed under the [GNU GPL v3](https*/www.gnu.org/licenses/gpl-3.0.html), but the *original contents* of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http*/creativecommons.org/licenses/by-nc-sa/4.0/). +-- By the way, DAU is licensed under the [GNU GPL v3](https*/www.gnu.org/licenses/gpl-3.0.html), but the *original contents* of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http*/creativecommons.org/licenses/by-nc-sa/4.0/). What a mouthful! I hate these licenses. CC BY-NC-SA. diff --git a/format/converted/markdown/readme/README.md b/format/converted/markdown/readme/README.md deleted file mode 100644 index fddd284..0000000 --- a/format/converted/markdown/readme/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# README - - -Characters: -- Content Warning -- Welcome -- What is the Dizzy AU/Dizzy Rewrite? -- Hold on, what's DAU? - -## Content Warning -Mature content is ahead. Please, be wary of these themes: - -- Mentions of suicide/suicidal thoughts - -- Depression or mentions of self-harm - -- Sexual themes - -- Trauma and traumatic events - -- Homosexual animals. - -By reading the Dizzy Rewrite, you acknowledge these warnings. - -[>> Read the Dizzy Rewrite](/STORY.md) - -## Welcome -Hello, welcome to the DAU/Dizzy Rewrite repository! - -## What is the Dizzy AU/Dizzy Rewrite? -The Dizzy Rewrite is a *revamped* version of the original Dizzy AU story. - -It's written in DAU, a new markup language made specifically for the Dizzy Rewrite. - -You can find the original Dizzy AU story at [MeowcaTheoRange/Dizzy-AU](https*/github.com/MeowcaTheoRange/Dizzy-AU). - -## Hold on, what's DAU? -DAU is an acronym for **"Dizzy AU"**. Pretty obvious there. - -It's a markup language made for creating fictional stories in an easy-to-transport manner. - -If you want to quickly whip up an HTML document and a Markdown file at the same time, you can use DAU to do so. - -In fact, this README page you're reading was originally made in DAU. Don't believe me? Check out [the source file](/format/source/readme.dau). - -Anyway, you're free to use DAU to start your fictonal endeavors today. Check out [the reuse guide](/format/converted/markdown/reuse.md) for more info. - --- By the way, DAU is licensed under the [GNU GPL v3](https*/www.gnu.org/licenses/gpl-3.0.html), but the *original contents* of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http*/creativecommons.org/licenses/by-nc-sa/4.0/). - diff --git a/format/source/json/readme.json b/format/source/json/readme.json index fbd2fd6..d810269 100644 --- a/format/source/json/readme.json +++ b/format/source/json/readme.json @@ -76,7 +76,7 @@ "If you want to quickly whip up an HTML document and a Markdown file at the same time, you can use DAU to do so.", "In fact, this README page you're reading was originally made in DAU. Don't believe me? Check out [the source file](/format/source/readme.dau).", "Anyway, you're free to use DAU to start your fictonal endeavors today. Check out [the reuse guide](/format/converted/markdown/reuse.md) for more info.", - "-- By the way, DAU is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html), but the :/original contents/: of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/)." + "-- By the way, DAU is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html), but the :/original contents/: of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/). What a mouthful! I hate these licenses. CC BY-NC-SA." ] } ] diff --git a/format/source/master.dau b/format/source/master.dau index 0010224..1a50b50 100644 --- a/format/source/master.dau +++ b/format/source/master.dau @@ -134,7 +134,7 @@ Its attempts are futile, and Miles stays asleep. Miles wanted to set an alarm tone, but he didn't like any of the ones the system came with, and he was too lazy to make his own. Finally, a call comes through. It plays a loud ringtone, notifying Miles that someone is calling him - duh. Miles writhes around, opening his eyes and looking around for his phone to hopefully deny the call and head back to sleep. - It's not on the coffee table, or in his hand... He looks down. It's, of course, on the floor. Miles picks up his phone, rubbing his eyes to read the text. + It's not on the coffee table, or in his hand... He looks down. It's, of course, on the floor. Miles picks up his phone, rubbing his eyes to read the screen. % "Silver work is calling. Swipe up to answer - Swipe down to reject" diff --git a/format/source/readme.dau b/format/source/readme.dau index d8f1bfb..86642f7 100644 --- a/format/source/readme.dau +++ b/format/source/readme.dau @@ -29,4 +29,4 @@ In fact, this README page you're reading was originally made in DAU. Don't believe me? Check out [the source file](/format/source/readme.dau). Anyway, you're free to use DAU to start your fictonal endeavors today. Check out [the reuse guide](/format/converted/markdown/reuse.md) for more info. - -- By the way, DAU is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html), but the :/original contents/: of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/). \ No newline at end of file + -- By the way, DAU is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.html), but the :/original contents/: of the Dizzy Rewrite repository are licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-nc-sa/4.0/). What a mouthful! I hate these licenses. CC BY-NC-SA. \ No newline at end of file diff --git a/format/source/reuse.dau b/format/source/reuse.dau new file mode 100644 index 0000000..0acc076 --- /dev/null +++ b/format/source/reuse.dau @@ -0,0 +1,165 @@ +? DAU Reuse Guide +- w :: Welcome +- cls :: Starting off - Cleanup +- ctd :: Starting off - Creating the document +- wr :: Writing DAU documents - Chapters +- dl :: Writing DAU documents - Dialogue +- etf :: Writing DAU documents - Extra text formatting +- par :: Parsing DAU documents + + w + So, you've decided to use DAU for your next story, huh? Well, go ahead. + It's really simple to set up and compile DAU. You can make your own parser, but a parser + converter is included for you to use. + By the way, as of right now, this parser can only compile to DAUDJSON (DAU Descriptive JSON) and Markdown. + + cls + First, you need to cleanup the place. + Simply remove the :'format': folder and its contents. + Then, recreate the :'format': folder, and add a :'source': folder within. + This is the easiest way to clean up the DAU working environment. + You can put your :'.dau': files inside of :'format/source':. + + ctd + Now, you have to create the document. + Go to :'format/source':, and create a new file with the :'.dau': extension. + :':':' + format/ + |- source/ + |- |- NewDAUFileYay.dau + ':':': + You're done! Now, open the :'.dau': file in your usual text editor. + + wr + DAU syntax is kinda easy to grasp. + Each file has a set of "chapters", with their own titles, locations, and even times. + :':':' + ? A chapter! + - jd :: Jane Doe + ':':': + First, a :'?': for telling DAU that you want to make a new chapter. + Then, you put your chapter title there. For example, :'A chapter!':. + And, if that's all you want, then you're done! + But, there are options! You can add a location, or a date and time. + If you'd like one of these, add the General Information separator, :'\:\:':. + Also, add an :'@': after your location if you want time. + Make sure to space between. + :':':' + ? A chapter! :: A location! @ A time! + - jd :: Jane Doe + ':':': + But, if you'd want to :/only/: add a time, you can skip out completely on the location text and just have the formatting :'\:\: @ A time!': + :':':' + ? A chapter! :: @ A time! + - jd :: Jane Doe + ':':': + OK, great! We have a chapter! Now, you may have noticed that there's a :'-': operator down there, instead of a :'?':. + That's a :[character defintion]:. You can also use it to define chapter headers, like in this document, but we'll keep it simple. + OK, so basically, a character definition goes like this. + :':':' + - jn :: John Doe + - jd :: Jane Doe + - bts :: Brent The Stickfigure + ':':': + First, a dash, for telling DAU that you want to make a new character. :'-': + Then, a special ID you can use to quickly refer to the character later on. :'bts': + After that, add the General Information separator, :'\:\:': + And finally, the name, :'Brent The Stickfigure':. + Also, names are technically separated by spaces. They get connected together when compiled, but this could possibly be used in the future to make the creation of DAU documents even easier. + + dl + DIALOGUE??? IN MY STORY??? Pah. + OK, but seriously, dialogue. + You kinda need dialogue, otherwise making chapters is pointless. + First, press :[Tab]:, to make a tabular space. + Then, type the ID of the character - :'bts': + :':':' + bts + ':':': + After that, start a new line and add :[two]: :[Tab]: presses. + Then, type in your dialogue! + :':':' + bts + YO SUP I'M BRENT THE STICK MAN!!! + ':':': + You can also add multiple lines of dialogue, just make sure to have two tabular spaces before each line. + :':':' + bts + YO SUP I'M BRENT THE STICK MAN!!! + MY FAVOURITE FOODS ARE GREEN AND YELLOW!!! + ':':': + Then, continue for multiple characters. + :':':' + bts + YO SUP I'M BRENT THE STICK MAN!!! + MY FAVOURITE FOODS ARE GREEN AND YELLOW!!! + jd + Brent, please leave. You are interrupting the peace. + bts + NO!!!!!!!!!!!!!!!!!!!!!!!!!! + ':':': + Completed file: + :':':' + ? A chapter! :: @ A time! + - jn :: John Doe + - jd :: Jane Doe + - bts :: Brent The Stickfigure + + bts + YO SUP I'M BRENT THE STICK MAN!!! + MY FAVOURITE FOODS ARE GREEN AND YELLOW!!! + jd + Brent, please leave. You are interrupting the peace. + bts + NO!!!!!!!!!!!!!!!!!!!!!!!!!! + ':':': + + etf + Hey, by the way, if you'd like to make your documents fancy, you can add "extra text formatting". + + -- Invisible formatting + :[Bold]: - :'\:[text]\:': + Makes your text visibly bolder. + Use this for emphasis, maybe? + :/Italic/: - :'\:/text/\:': + Makes your text italicized. + Use this for emphasis, too. + :'Code block': - :'\:'text'\:': + Makes your text monospace, if it isn't already. + Use this for contextual stuff, or actual code. + -- Visible formatting + Escaped formatting operator - :'\\:': + Prints a single colon. You don't have to use this to write a colon, but only to negate formatting with the operator. + The :'\': should be placed directly before the colon, always! + Dialouge - "text" + Tells DAU that this piece of text is spoken. + Recieved message - << "text" + Tells DAU that this piece of text has been recieved by the protagonist within the context of the story, by any means. + Sent message - "text" >> + Tells DAU that this piece of text has been sent by the protagonist within the context of the story, by any means. + + par + Great! Now, you need to parse the DAU file. + The Dizzy-Rewrite repository comes with a built-in DAU parser for your needs. + Go to the :[root]: of the repository folder, and open a terminal. + Current formats you can export to with the built-in parser: + + - Markdown + - Plaintext + + ...sorry for the lack of output languages. More coming soon! + Type :'node code/filer.js [FILENAME WITHOUT DAU EXTENSION] [OUTPUT LANGUAGE]': + :':':' + [BRENT@STICKMAN-COMPUTER MY-STORY]$ node code/filer.js NewDAUFileYay Markdown + ':':': + This should create a new folder, and add contents. + :':':' + format/ + |- converted/ + |- |- markdown/ + |- |- |- NewDAUFileYay/ + |- |- |- |- A_Chapter_.md + |- |- |- NewDAUFileYay.md + |- source/ + |- |- NewDAUFileYay.dau + ':':': + Inside :'format/converted/[OUTPUT LANGUAGE]': will be your output file. \ No newline at end of file