Project

General

Profile

Actions

Wordpress » History » Revision 5

« Previous | Revision 5/6 (diff) | Next »
Denis 'GNUtoo' Carikli, 02/26/2024 05:10 PM
fix bug with \n being removed and not replaced with a space as some words have \n without space between them.


Wordpress

Plugins

Plugin License Free software directory review page
Akismet Anti-spam: Spam Protection
Companion Auto Update
Post Notification by Email GPLv2+ Post_Notification_by_Email

Replicant also has a modified Post Notification by Email modified by Paul Kocialkowski from version Version 4.1.2 of Post Notification by Email.

Research on markdown with Wordpress.

Using markdown with haunt.

There is work in progress to migrate the Wordpress blog to a static website that uses markdown.

Haunt is a good candidate for that and there was some work to try it out in the contrib/GNUtoo/haunt-blog repository.

So until this work is finished, we can still use that work to work on blog posts with a markdown format and then convert that markdown to html suitable for Wordpress.

To do that, once the HTML page has been created, you can this script to prettify it and rearrange the paragraphs not to have line breaks inside (which are interpreted as line breaks in Wordpress):

#!/usr/bin/env python3
# encoding: utf-8
# Copyright (C) 2020, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import bs4
import enum
import os
import re
import sys

def usage(progname):
    print("{} path/to/file.html".format(progname))
    sys.exit(1)

def fixup_html(html):
    open_p = 0
    buf = [None]  * 4
    for c in html:
        buf[0] = buf[1]
        buf[1] = buf[2]
        buf[2] = buf[3]
        buf[3] = c

        if buf[1] == '<' and buf[2] == 'p' and buf[3] == '>':
            open_p += 1
        if buf[0] == '<' and buf[1] == '/' and buf[2] == 'p' and buf[3] == '>':
            open_p -= 1

        if c == '\n' and open_p > 0:
            print(' ', end='')
        else:
            print(c, end='')
def main():
    if len(sys.argv) != 2:
        usage(sys.argv[0])

    html_file_path = sys.argv[1]

    with open(html_file_path) as html_file:
        soup = bs4.BeautifulSoup(html_file, 'html.parser')
        pretty_html = soup.prettify()
        fixup_html(pretty_html)

if __name__ == '__main__':
    main()

This produces something like that:

<!DOCTYPE html>
<head>
 <meta charset="utf-8"/>
 <link href="static/twentyeleven-style-20231107.css" rel="stylesheet"/>
 <title>
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences. — Replicant
 </title>
</head>
<body>
 <header>
  <nav id="access">
   <ul>
    <li>
     <a href="https://www.replicant.us">
      Home
     </a>
    </li>
    <li>
     <a href="https://blog.replicant.us">
      Blog
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/wiki">
      Wiki
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/issues">
      Tracker
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/boards">
      Forums
     </a>
    </li>
   </ul>
  </nav>
 </header>
 <h2>
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences.
 </h2>
 <div>
  <h1>
   Replicant current status:
  </h1>
  <p>   The last Replicant release is still based on Android 6.0.  </p>
  <p>   In the previous years, a lot of work was done to make the Galaxy SIII(GT-I9300) usable with an upstream kernel, both on graphics and on themodem.  </p>
[...]
    <p>     The main maintainer of Replicant also met with PaulKocialkowski. Before that meeting he thought that on GNU/Linux the     <a href="https://gitlab.com/mobian1/eg25-manager">      eg25-manager program     </a>     forthe Pinephone only did simple things like setting up udev rules andhad simple hacks to make the modem work fine, and he thought thatall stability issues were to be handled by Modem Managerinstead. But the EC 25 Manager is might also be monitoring the modemand restarting it when it crashed. This could explain modemstability issues with Android / GloDroid on PinePhones with 3GiB ofRAM. And so the fix would be to port / reimplement that feature tomake this model usable.    </p>
   </li>
  </ul>
 </div>
</body>

So first add the article title in wordpress, and then you can start switch to the code editor and paste the article starting right after the header and first top level title:

<!DOCTYPE html>
<head>
 <meta charset="utf-8"/>
 <link href="static/twentyeleven-style-20231107.css" rel="stylesheet"/>
 <title>
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences. — Replicant
 </title>
</head>
<body>
 <header>
  <nav id="access">
   <ul>
    <li>
     <a href="https://www.replicant.us">
      Home
     </a>
    </li>
    <li>
     <a href="https://blog.replicant.us">
      Blog
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/wiki">
      Wiki
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/issues">
      Tracker
     </a>
    </li>
    <li>
     <a href="https://redmine.replicant.us/projects/replicant/boards">
      Forums
     </a>
    </li>
   </ul>
  </nav>
 </header>
 <h2>
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences.
 </h2>
 <div>

Also ommit the end:

 </div>
</body>

Updated by Denis 'GNUtoo' Carikli about 2 months ago · 5 revisions

Also available in: PDF HTML TXT