• 1 Post
  • 24 Comments
Joined 1 year ago
cake
Cake day: February 17th, 2024

help-circle
  • You’re not wrong. Again, my logic for that the crazy person is on the warpath towards other hosting companies. For a time he had cut WPEngine off from wordpress.org, which meant thousands of regular people and business running wordpress couldn’t update their plugins or wordpress core because they had no access to the .org registries.

    Mullenweg isn’t going to do that to his own company. I think Mullenweg is a piece of shit, and I would steer clear of wordpress.com. My previous comment pointing towards .com is dumb.


  • harsh3466@lemmy.mltoSelfhosted@lemmy.worldSelf host websites
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 hours ago

    Mullenweg owns wordpress.com. It’s arguably the only safe place to host WordPress since it’s his company and while he seems willing to burn all goodwill down to the ground for wordpress open source, hes (probably) not going to burn his own company and cash cow to the ground.

    I mean, it’s not a great option, and I may be stupid for saying that, but that was my reasoning for saying so.

    TBH, I’d just host it myself if I was going to do it.


  • harsh3466@lemmy.mltoSelfhosted@lemmy.worldSelf host websites
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 hours ago

    FWIW, it might be better to avoid wordpress hosting UNLESS you go with hosting from wordpress.com, since there’s kind of an all out war in the wordpress world right now and the fallout to people who just want their websites to work is unknown.

    The tl;dr is that Matt Mullenweg, wordpress founder and owner/CEO of Automattic (which is the company that runs wordpress.com), has engaged in a Trumpish crazy war with wordpress hosting engine WPEngine, and in doing so has arbitrarily (in the name of his war) been doing crazy shit with the open source wordpress project.




  • Oh god! I’m sorry about the missing )! I must have dropped it when copying things from my notes over to post the comment! (≧▽≦)

    Despite my error, I’m glad it worked, and even happier that you were able to take what we had worked out and modify it further to fit your other requirements. It’s fun helping each other out, and it’s also great learning.

    I learn by problem solving, so I’ve got all my notes from working on this in my knowledge base as well!

    In the future, feel free to ping me if you need help with other linux/cli/bash things. As I’ve mentioned before I’m no expert, but happy to help where I can.




  • Okay. To address the %20 and the https links, and the placeholder links, I came up with a bash script to handle this.

    Because of the variation in the links, instead of trying to write a sed command that will match only %20 in anchor markdown links, and placeholder links, while ignoring https links and ignoring all other text in the document.

    To do that, I used grep, a while loop, IFS, and sed

    Here’s the script:

    #! /bin/bash
    
    mdlinks="$(grep -Po ']\((?!https).*\)' ~/mkdn"
    
    while IFS= read -r line; do
    	dashlink="$(echo "$line" | sed 's/%20/-/g')"
    	sed -i "s/$line/${dashlink}/" /path/to/file
    done <<<"$mdlinks"
    

    I’m not sure how familiar you are with bash scripting, so I’ll do the same breakdown:

    #! /bin/bash - This tells the shell what interpreter to use for the script. In this case it’s bash.

    mdlinks="$(grep -Po ']\((?!https).*\)' /path/to/file" - This line uses grep to search for markdown link enclosures excluding https links and to output only the text that matches and saves all of that into a variable called mdlinks. Each link match will be a new line inside the variable.

    The breakdown of the grep command is as followes:

    grep - invokes the grep command

    -Po - two command flags. The P tells grep to use perl regular expressions. The o tells grep to only print the output that matches, rather than the entire line.

    ' - opens the regex statement

    ]\( - finds a closing bracket followed by an opening parentheses

    (?!https) - This is a negative look ahead, which a feature available in perl regex. This tells grep not to match if it finds the https string. The parentheses encloses the negative look ahead. The ?! Is what indicates it’s a negative look ahead, and the https is the string to look for and ignore.

    ' - closes the regex statement

    /path/to/file - the file to search for matches

    while IFS= read -r line; do - this invokes a while loop using the Internal Field Separator (IFS=), which by default includes newline character. This allows the loop to take in the variable containing all of the matched links and separate them line by line to work on one at a time. The read command does what it says and reads the input given. In this case our variable mdlinks. The -r flag tells read to ignore the backslash character and just treat it as a normal part of the input. line is the variable that each line will be saved in as they are worked through the loop. The ; ends while setup, and do opens the loop for the commands we want to run using the input saved in line.

    dashlink="$(echo "$line" | sed 's/%20/-/g')" - This command sequence runs the markdown link saved in the line variable into sed to find all instances of %20 and replace them with a -.

    dashlink - the variable we’re saving the new link with dashes to.

    = - separates the variable from the input being saved into the variable.

    " - opens this command string for variable expansion.

    $ - tells bash to do command substition, meaning that the output of the following commands will be saved to the variable, rather than the actual text of the commands that follows.

    ( - opens the command set

    echo - prints the given text or arguments to standard output, in this case the given argument is the variable $line

    " - tells bash to expand any variables contained within the quote set while ignoring any nonstandard characters like spaces or special shell characters that are saved in the variable.

    $line - the variable containing our active markdown link from the text document

    " - the closing quote ending the argument and the expansion enclosure

    | - This is a pipe, which redirects the standard output of the command on the left into the command on the right. Meaning we’re taking the markdown link currently saved in the variable and feeding it into sed

    sed - invokes sed so we can manipulate our text, and because sed is receiving redirected input, and we’ve specified no flags, the modified text will be printed to standard output.

    's/%20/-/g' - Our pattern match/substitution, which will find all occurrences of the string %20 in the markdown link fed into sed and replace them with -.

    )" - closes our command sequence for command substitution, and the variable expansion. At this point the text printed to standard output by sed is saved to the variable dashlink

    The next line is: sed -i "s/$line/${dashlink}/" /path/to/file, which uses sed to take the line and dashlink variables and use them to find the exact original markdown link in the text containing the %20 sequences, and replace it with the properly formatted markdown link with dashes.

    sed -i - invokes sed and uses the -i flag to edit the file in place.

    " - The double quote enclosure allows the expansion of variables in the pattern match/replacement sequence so it searches for the markdown link, and not the literal text string $line.

    s/ - opens our match/modify sequence.

    $line - the original markdown link that will be found

    / - ends the pattern matching section

    ${dashlink} - The variable containing the previously modified markdown link that now has dashes. This expands to that properly formatted link which will be written into the text file replacing the malformed link. I don’t know why this link has to be enclosed in curly braces while the first one does not.

    /" - ends the text modification section and closes the variable expansion.

    /path/to/file - the file to be worked on

    Finally we have done<<<"$mdlinks", which ends the while loop and feeds the mdlinks variable into it.

    done - closes the while loop

    <<< - This feeds the given argument into the while loop for processing

    " - expands the variable within while ignoring nonstandard characters

    $mdlinks - the variable we’re feeding in with all of our links containing %20, except for https links.

    " - closes the variable expansion.

    If you’ve never written/created your own bash script, here’s what you need to do.

    • in your home directory, or in the directory you’re working in with these files, use a text editor like vim or nano or gedit or kate or whatever plain text editor you want to to create a new file. Call the file whatever you want.

    • Paste the entirety of the script text into the file. Modify the file paths as needed to work the file you want to work. if working multiple files, you’ll need to update the script for each new file path as you finish one and move on to the next

    • Save and exit the file

    • Make the file executable at the terminal with sudo chmod +x /path/to/script/file

    • To run it:

      • Change directory to the directory that contains the script file (if you’re not already there)
      • at the command line use the command . ./name-of-script-file

  • I checked the locale and it is correct. I’m on Arch, and I just installed neovim to compare the cursor and typing behaviors, and in neovim it acts as expected when I type the ~.

    I did notice that in vim, I now have a blinking block cursor in insert mode as well as in visual mode, while in neovim, it’s a block cursor in visual mode and a vertical bar cursor in insert mode. This was the normal behavior in vim prior to whatever the heck I did.

    Edit: grammar






  • Feel free to ping me if you want some help! I’d say I’m intermediate with regex, and I’m happy to help where I can.

    Regarding the other file, you could pretty easily modify the command I gave you to adapt to the example you gave. There’s two approaches you could take.

    This is focused on the first regex in the command. The second should work unmodified on the other files if they follow the same pattern.

    Here’s the original chunk:

    s|]\(#.+\)|\L&|

    In the new example given, the # is preceded by readme.md. The easy modification is just to insert readme\.md before the # in the expression, adding the \ before the . to escape the metacharacter and match the actual period character, like so:

    s|]\(readme\.md#.+\)|\L&|

    However, if you have other files that have similar, but different patterns, like (faq.md#%20link%20text), and so on, you can make the expression more universal by using the .* metacharacter sequence. This is similar to the .+ metacharacter sequence, with one difference. The + indicates one or more times, while the * indicates zero or more times. So by using .* before the # you can likely use this on all the files if they follow the two pattern examples you gave.

    If that will work, this would be the expression:

    s|]\(.*#.+\)|\L&|

    What this expression does is:

    Find find a closing bracket followed by a opening parentheses followed by any sequence of characters (including no characters at all) until finding a pound/hash symbol then finding one or more characters until finding a closing parentheses, and convert that entire matched string to lowercase.

    And with that modified expression, this would be the full command:

    sed -ri 's|]\(#.+\)|\L&|; s|%20|-|g' /path/to/somefile
    

    Edit: grammar

    Edit 2: added the full modified command.


  • Okay, here’s the command and a breakdown. I broke down every part of the command, not because I think you are dumb, but because reading these can be complicated and confusing. Additionally, detailed breakdowns like these have helped me in the past.

    The command:

    sed -ri 's|]\(#.+\)|\L&|; s|%20|-|g' /path/to/somefile
    

    The breakdown:

    sed - calls sed

    -r - allows for the use of extended regular expressions

    -i - edit the file given as an argument at the end of the command (note, the i flag must follow the r flag, or the extended regular expressions will not be evaluated)

    Now the regex piece by piece. This command has two substitution regex to break down the goals into managable chunks.

    Expression one is to convert the markdown links to lowercase. That expression is:

    's|]\(#.+\)|\L&|;

    The goal of this expression is to find markdown links, and to ignore https links. In your post you indicate the markdown links all start with a # symbol, so we don’t have to explicitly ignore the https as much as we just have to match all links starting with #. Here’s the breakdown:

    ' - begins the entire expression set. If you had to match the ' character in your expression you would begin the expression set with " instead of '.

    s| - invoking find and replace (substitution). Note, Im using the | as a separator instead of the / for easier readability. In sed, you can use just about any separator you want in your syntax

    ]\(# - This is how we find the link we want to work on. In markdown, every link is preceded by ]( to indicate a closing of the link text and the opening of the actual url. In the expression, the ( is preceded by a \ because it is a special regex character. So \( tells sed to find an actual closing parentheses character. Finally the # will be the first character of the markdown links we want to convert to lowercase, as indicated by your example. The inclusion of the # insures no https links will be caught up in the processing.

    .+ - this bit has two parts, . and +. These are two special regex characters. the . tells sed to find any character at all and the + tells it to find the preceding character any number of times. In the case of .+, it’s telling sed to find any character and this pattern can repeat any number of times. You might think this will eat ALL of the text in the document and make it all lowercase, but it will not because of the next part of the regex.

    \) - this tells sed to find a closing parentheses. Like the opening parenthese, it is a special regex character and needs to be escaped with the backslash to tell sed to find an actual closing parentheses character. This is what stops the command from converting the entire document to lowercase, because when you combine the previous bit with this bit like so .+\), you’re telling sed to find any character UNTIL you find a closing parentheses.

    | - This tells sed we’re done looking for text to match. The next bits are about how to modify/replace that text

    \L - This tells sed to convert the given text to all lowercase

    & - Tells sed to convert the entire pattern matched to lowercase.

    ; - this tells sed that this is the end of the first expression, and that more are coming.

    So all together, what this first expression does is: Find a closing bracket followed by an opening parentheses followed by a pound/hash symbol followed by any number of any characters until finding a closing parentheses. Then convert that entire chunk of text to lowercase. Because symbols don’t have case you can just convert the entire matched pattern to lowercase. If there were specific parts that had to be kept case sensitive, then you’d have to match and modify more precisely.

    The next expression is pretty easy, UNLESS any of your https links also include the string %20:

    If no https links contain the %20 string, then this will do the trick:

    s|%20|-|g'

    s| - again opens the expression telling sed wer’re looking to substitute/modify text

    %20 - tells sed to find exactly the character sequence %20

    | - ends the pattern matching portion of the expression

    - - tells sed to replace the matched pattern with the exact character -

    | - tells sed that’s the end of the modification instructions

    g - tells sed to do this globally throughout the document. In other words, to find all occurrances of the string %20 and replace them with the string -

    ' - tells sed that is the end of the expression(s) to be evaluated.

    So all together, what this expression does is: Within the given document, find every occurrence of a percent symbol followed by the number two followed by the number zero and replace them with the dash character.

    /path/to/somefile - tells sed what file to work on.

    Part of using regex is understanding the contents of your own text, and with the information and examples given, this should work. However, if the markdown links have different formatting patterns, or as mentioned any of the https links have the %20 string in them, or other text in the document might falsely match, then you’d have to provide more information to get a more nuanced regex to match.