Skip to content

Commit

Permalink
Modified package dependencies for node and added some useful informat…
Browse files Browse the repository at this point in the history
…ion at the home page
  • Loading branch information
alexneri committed Jun 16, 2023
1 parent ae7ec35 commit 785279f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .replit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

hidden = [".config", "package-lock.json"]
run = "npm run start"
run = "node app.js"

[[hints]]
regex = "Error \\[ERR_REQUIRE_ESM\\]"
Expand Down
34 changes: 19 additions & 15 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ASCIIDOC EDITOR
// Written by Alexander Neri 04 June 2023
// github.com/alexneri/asciiedit

const express = require('express');
const asciidoctor = require('asciidoctor')();
const TurndownService = require('turndown');
Expand All @@ -9,29 +13,29 @@ app.set('view engine', 'ejs');
app.use(express.static('public'));

app.get('/', (req, res) => {
res.render('index');
res.render('index');
});

app.post('/preview', express.text({ type: '*/*' }), (req, res) => {
const asciidocSource = req.body;
const html = asciidoctor.convert(asciidocSource);
res.send(html);
const asciidocSource = req.body;
const html = asciidoctor.convert(asciidocSource);
res.send(html);
});

app.post('/reverse', express.text({ type: '*/*' }), (req, res) => {
const html = req.body;
const turndownService = new TurndownService();
const markdown = turndownService.turndown(html);
const html = req.body;
const turndownService = new TurndownService();
const markdown = turndownService.turndown(html);

exec(`echo "${markdown}" | pandoc -f markdown -t asciidoc`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
res.send(stdout);
});
exec(`echo "${markdown}" | pandoc -f markdown -t asciidoc`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
res.send(stdout);
});
});

app.listen(port, () => {
console.log(`Asciidoc Editor listening at http://localhost:${port}`);
console.log(`Asciidoc Editor listening at http://localhost:${port}`);
});
5 changes: 5 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"ace-builds": "^1.22.0",
"asciidoctor": "^2.2.6",
"child_process": "^1.0.2",
"ejs": "^3.1.9",
"express": "^4.18.2",
"turndown": "^7.1.2"
Expand Down
5 changes: 4 additions & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,22 @@
<div class="container wide-container">
<h1 class="my-4">Asciidoc Editor</h1>
<blockquote>
<p>By Alex Neri</p>
<p>By <a href="https://github.com/alexneri" target="_blank">Alex Neri</a></p>
</blockquote>
Welcome to the ASCIIDOC Editor! This editor allows you to edit your documentation in Asciidoc format. Featuring a WYSWYG preview, you can make quick edits, and copy the changed code back into your adoc files. <strong>NO DATA IS SAVED</strong>, so make sure to copy and paste your changes once done.<br /><br />
<strong>NOTE:</strong> This is the test-dev build, which always reflects the latest changes in the <a href="https://github.com/alexneri/asciiedit" target="_blank">repo</a>. Issues? File <a href="https://github.com/alexneri/asciiedit/issues" target="_blank">here</a>. Very large swathes of code will return an error, so copy or edit code in smaller chunks.<br /><br />
<!--<pre id="editor"></pre>-->
<!--<button class="btn btn-primary mb-3">Preview</button>-->
<!--<div id="preview" contenteditable="true"></div>-->
<!--<button class="btn btn-success mt-3">Save</button>-->
<div class="row">
<div class="col-12 col-lg-6">
Code Editor
<pre id="editor"></pre>
<button class="btn btn-primary mb-3" onclick="preview()">Preview code</button>
</div>
<div class="col-12 col-lg-6">
Preview & Editor
<div id="preview" contenteditable="true"></div>
<button class="btn btn-success mt-3" onclick="save()">Save to code</button>
</div>
Expand Down

0 comments on commit 785279f

Please sign in to comment.