Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transform: ({
file,
contents,
}: {|
file: PhenomicContentFile,
contents: Buffer,
|}) => {
debug(`transforming ${file.fullpath}`);
const ad = asciidoctor();
const doc = ad.load(contents, adDefaultOptions);
const tags = doc.getAttribute("tags");
const content = ad.convert(contents, adDefaultOptions);
// $FlowFixMe it's here, I can feel it Flow
const body = processor.processSync(content).contents;
const partial = {
...extractMetaFromBodyNode(body),
...doc.attributes.$$smap,
date:
doc.getAttribute("date") || doc.getAttribute("revdate") || undefined,
// title fallback
title: doc.getAttribute("doctitle") || file.name,
layout: doc.getAttribute("layout"),
showdate: doc.getAttribute("nodate", true),
const giteaClient = require('./gitea_client');
const gitClient = require('./git_client');
const bodyParser = require('body-parser');
const uuid = require('uuid');
const promMid = require('express-prometheus-middleware');
const Prometheus = require('prom-client');
const querystring = require('querystring');
const flattenDeep = require('lodash.flattendeep');
const proxy = require('express-http-proxy');
const { sync, closeConnection, getUserWalkthroughs, setUserWalkthroughs, validUrl } = require('./model');
const OPENSHIFT_PROXY_PATH = '/proxy/openshift';
const app = express();
const adoc = asciidoctor();
app.use(bodyParser.json());
app.use(OPENSHIFT_PROXY_PATH, proxy(`https://${process.env.OPENSHIFT_API}`, {
proxyReqOptDecorator: function(proxyReqOpts, _) {
proxyReqOpts.rejectUnauthorized = false
return proxyReqOpts;
}
}));
// prometheus metrics endpoint
app.use(
promMid({
metricsPath: '/metrics',
collectDefaultMetrics: true,
requestDurationBuckets: [0.1, 0.5, 1, 1.5]
})
function processAsciidoc(text) {
const ad = asciidoctor();
const doc = ad.load(text, defaultOptions);
const data = {
...doc.attributes.$$smap,
contents: ad.convert(text, defaultOptions)
};
data.date =
doc.getAttribute("date") || doc.getAttribute("revdate") || undefined;
data.title = doc.getAttribute("doctitle");
data.layout = doc.getAttribute("layout");
data.showdate = doc.getAttribute("nodate", true);
data.tags = doc.getAttribute("tags");
data.tags = data.tags
? data.tags.split(",").map(tag => kebabCase(deburr(tag)))
: [];
getDocContent() {
if (this.props.template) {
return this.state.docContent;
}
const adoc = Asciidoctor();
if (!this.state.docContent) {
return null;
}
return adoc.convert(this.state.docContent, { loaded: true, attributes: this.props.attributes });
}
const Asciidoc = ({ text, className }) => {
const asciidoctor = Asciidoctor();
const html = asciidoctor.convert(text);
return (
<div>
);
};
</div>
const React = require('react');
const Asciidoctor = require('asciidoctor.js');
const bootstrap = require('./boostrap');
const asciidoctor = Asciidoctor();
require('asciidoctor-html5s');
const options = {
attributes: {
showtitle: true,
icons: 'fonts@',
'source-highlighter': 'highlightjs@',
},
backend: 'html5s',
};
const fetchReferences = (adocDoc, transformValue = null) => adocDoc.$references().$fetch('ids').$to_a().map(([key, content]) => {
const caption = content.replace(/<[^>]*>?/g, '');
return {
value: transformValue ? transformValue(key, caption) : key,
caption,
const parseAdoc = (rawAdoc, attrs) => asciidoctor().load(rawAdoc, { attributes: attrs });
}
}
export default class AsciiDocProvider implements TextDocumentContentProvider {
static scheme = 'adoc-preview';
private _onDidChange = new EventEmitter();
private resultText = "";
private lastPreviewHTML = null;
private lastURI = null;
private needsRebuild : boolean = true;
private editorDocument: TextDocument = null;
private refreshInterval = 1000;
private asciidoctor = Asciidoctor(asciidoctor_config);
private resolveDocument(uri: Uri): TextDocument {
const matches = workspace.textDocuments.filter(d => {
return MakePreviewUri(d).toString() == uri.toString();
});
if (matches.length > 0) {
return matches[0];
} else {
return null;
}
}
public provideTextDocumentContent(uri: Uri): string | Thenable {
const doc = this.resolveDocument(uri);
return this.createAsciiDocHTML(doc);
}
return () => {
if (!cache.instance) {
cache.instance = asciidoctorFactory();
}
return cache.instance;
};
}();