pagedown


How can I prevent pagedown from displaying images?


I am using pagedown as a text editor, but I don't want users to be able to embed images in their content (links are ok).
How can I prevent images from displaying? Preferably I don't want pagedown to generate the html for images at all.
To remove the ability to add images with a button, you can comment out a couple sections of Markdown.Editor.js:
To make sure the keyboard shortcut is disabled, comment out the case "g" section below:
...
case "k":
doClick(buttons.code);
break;
/*
case "g":
doClick(buttons.image);
break;
*/
case "o":
doClick(buttons.olist);
break;
...
To eliminate the image button, comment out that section:
...
buttons.code = makeButton("wmd-code-button", getString("code"), "-80px", bindCommand("doCode"));
/*
buttons.image = makeButton("wmd-image-button", getString("image"), "-100px", bindCommand(function (chunk, postProcessing) {
return this.doLinkOrImage(chunk, postProcessing, true);
}));
*/
makeSpacer(2);
...
A saavy markdown user might know how to enter an image without using the button, however. To catch this, you could do something like the following in Markdown.Converter.js:
Go to the _DoImages function, and replace this line:
text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag);
with something like this one:
text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, "IMAGES NOT SUPPORTED");
And again, this line:
text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag);
with this:
text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, "IMAGES NOT SUPPORTED");
Now whenever the converter finds markdown for an image, it'll replace it with "IMAGES NOT SUPPORTED", including in the preview window. This may or may not be exactly what you want, but you could also replace with an empty string, other tag, ...

Related Links

How can I prevent pagedown from displaying images?
Hide buttons on pagedown

Categories

HOME
algorithm
assembly
turing-machines
ns-3
angular-formly
case
3d
sh
requirements
scripting
rds
onclick
startup
redis-sentinel
opengl-es-3.0
radgridview
mvc-mini-profiler
pyramid
asp.net-core-webapi
selinux
ios10.2
itunes
maze
custom-post-type
boost-asio
livelink
cart
testbed
dumpbin
nested-lists
slacktextviewcontroller
xajax
engine.io
raft
google-earth-engine
nohup
xv6
logback-groovy
apollostack
xmldocument
nanoc
robomongo
seq
py2neo
slackware
grails-plugin
custom-lists
model-associations
aurora
fink
highland.js
batik
dnssec
cwrsync
umlgraph
beatsmusic
device-tree
jama
kissfft
visual-studio-express
cocoalibspotify-2.0
tlf
cnf
route-provider
android-icons
composite-component
windows-98
fb.ui
twisted.web
nokia-s40
wcf-configuration
procedures
matlab-load
winmain
lr
jqote
luajava
undefined-index
zen
java1.4
ifilter

Resources

Encrypt Message