The Markdown benefits

The Markdown format It is a format that guarantees the maximum of graphic rendering with the minimum of code. Why is this important?

A rich graphic rendering, on the one hand, is a value because the things that are written (and then they must be correctly readable) do not all have the same importance. And, on the other hand, the minimal use of the code helps to reduce the size of the file, occupying as little space as possible on the device. Moreover, Markdown helps also to modify directly and easily the code, since it is an extremely “clean” code and very similar to its graphic rendering.

titles

A title must hit more than the body of the text. And a main title must hit more than secondary titles. A way to do this is a different size of characters. Markdown can do this.

the TOC

The use of titles is also useful for “browsing” quickly in a document, jumping from one title to another, without having to flow the whole body of the text. A good text viewer is able to provide a TOC (Table of Content) which allows you to browse quickly between the parts of the document (characterized by higher or lesser level titles).

text formatting

But the body of the text is also important to highlight what is most important from what is less: bold and italics are ways to do it.

blockquotes

Then it is good to be able to distinguish between what the author of the document and the blocks of text said by other authors (i.e. long citations) writes, and for this there is the blockquote, which is good is also graphically distinct from the rest of the body of the text.

LibreCalc data sorting problem

After importing a csv file, you could not be able to sort your data, if you have to sort “date” cells. Indeed, even setting cells as date format and the right date format (such as GG/MM/AAAA or the like), you couldn’t be able to sort as expected your data.

To fix this, as explained here, you should import in LibreCalc a csv file with something like “date” checking “Detect special numbers” field. In this way you should be able to sort your items by the “date” columns.

Customize an android shortcut icon

You can use Shortcut Maker: as said here, “to change individual app icons on your phone for first-party and third-party apps just the same. It’s a popular alternative method that lets you tweak the app icons on your home screen.”

pdf editor (linux)

The best pdf editor in linux is, IMO, Master PDF. That is not, however, an open source application: to get its full function you must buy a (quite expensive) license.
You can bypass this problem using a previous pdf master release, that have less features, but all free. Remember to lock (pin) this relaese, otherwise your software manager will update it to the new ones.

There are others pdf editor, but not so good

  • LibreDraw i.g. can edit a pdf, but the result a very untidy (detroying original formattation) and huge-sized (4 or 5 bigger than the original one) page.
  • Scribus can edit a pdf, but not the outlines, and in a very poor mode. Moreover big pdf files are a problem for Scribus.

to install an appimage

Make an appimage executable is absolutely easy. But less easy is to associate that application with its mime-type files. Especially if that type of file doesn’t exist already on your system.

A very easy way, then, is to go to the appimage folder and, in a terminal, do

(sudo) ./appimage-name install

With this command all will be ready, correctly set, as if that application wouldn’t be an appimage, but a “regular” one.

Syling title attribute

It seems impossible: the only possibility is use date-title, and :after :hover:after pseudo-elements.

automatize your website

Recently I managed to make some new improvements about website automation

After the automation of gallery, in a previous post, I did this other automation (with php):

list php pages with a given name

With the following code, you can list (and link) all webages php files containing in its filename the variable you can set:

<?php
echo "<h3>testi on-line di $autore</h3>";
echo "<ul class=\"flexmenu\">\n";

// Escape special characters in $autore to use safely in glob pattern
$phpfiles = glob("$path/*" . preg_quote($autore_di, '/') . "*.php"); // Get all PHP files with $autore in the name

foreach ($phpfiles as $phpfile) {
    $contents = file_get_contents($phpfile);

    preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatch);
    preg_match('/\$subtitle\s*=\s*"(.*?)";/', $contents, $subtitleMatch);
    preg_match('/\$description\s*=\s*"(.*?)";/', $contents, $descriptionMatch);
    preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatch);

    $title = $titleMatch[1] ?? 'No title';
    $subtitle = $subtitleMatch[1] ?? 'No subtitle';
    $order = $orderMatch[1] ?? '';
    $description = $descriptionMatch[1] ?? 'No description';

    // Correctly extract the filename
    $filename = $phpfile; // Use basename on $phpfile directly

    echo " <li role='menuitem' style=\"order:$order\"><a href=\"{$filename}\">{$title}</a>, <i>{$subtitle}</i>: {$description}</li>\n";
}

echo "</ul>";


echo "<h3>testi on-line su $autore</h3>";
echo "<ul class=\"flexmenu\">\n";

// Escape special characters in $autore to use safely in glob pattern
$phpfiles = glob("$path/*" . preg_quote($autore_su, '/') . "*.php"); // Get all PHP files with $autore in the name

foreach ($phpfiles as $phpfile) {
    $contents = file_get_contents($phpfile);

    preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatch);
    preg_match('/\$subtitle\s*=\s*"(.*?)";/', $contents, $subtitleMatch);
    preg_match('/\$description\s*=\s*"(.*?)";/', $contents, $descriptionMatch);
    preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatch);

    $title = $titleMatch[1] ?? 'No title';
    $subtitle = $subtitleMatch[1] ?? 'No subtitle';
    $order = $orderMatch[1] ?? '';
    $description = $descriptionMatch[1] ?? 'No description';

    // Correctly extract the filename
    $filename = $phpfile; // Use basename on $phpfile directly

    echo " <li role='menuitem' style=\"order:$order\"><a href=\"{$filename}\">{$title}</a>, <i>{$subtitle}</i>: {$description}</li>\n";
}

echo "</ul>";
?>

You can call that code in a webpage, with something like this:

<?php
/*files beginning with i must be uppercase */
$path="../testi";// your path
$autore="Aristotele";
$autore_di="Aristotele[di]";//texts of $autore
$autore_su="Aristotele[su]";//texts about $autore
include "$root/lista-files-testi-[autore]-online-con-metatags.inc";
?>

automatically list files in a website menu

You can create an automatic menu list of your files in a given folder, and in a folder with the same name of one file (without extension, of course). With a code like the following:

<?php
$phpfiles = glob("{$root}/$menupath/[^index]*.php");

foreach ($phpfiles as $phpfile) {
  $contents = file_get_contents($phpfile);

  // Match $order
  preg_match('/\$order\s*=\s*"(.*?)";/', $contents, $orderMatches);

  // Match $title
  preg_match('/\$title\s*=\s*"(.*?)";/', $contents, $titleMatches);

  // Assign the values
  $order = $orderMatches[1] ?? null;
  $title1 = $titleMatches[1] ?? null;

  $filename1 = basename($phpfile); // Get only the file name
  $filename = pathinfo($phpfile, PATHINFO_FILENAME);
  $filename = str_replace('-', ' ', $filename); // Replace hyphens with spaces in the filename
  $filename = ucfirst($filename); // Optional: Capitalize the first letter for better readability
  $link = "$root/$menupath/{$filename1}"; // Create the relative link

  // Start the list item for the menu
  echo "<li role='menuitem' style=\"order:$order\"><a href=\"{$link}\">{$title1}</a>";

  // Check if a sub-menu is required (look for a folder matching the filename)
  $folder = "{$root}/$menupath/{$filename}";
  if (is_dir($folder)) {
    // If the subfolder exists, generate the sublist automatically
    $subfiles = glob("{$folder}/[^index]*.php");
    if (count($subfiles) > 0) {
      echo "<ul class='flexmenu'>"; // Start sublist
      foreach ($subfiles as $subfile) {
        $subfileName = basename($subfile);
        $subfileTitle = pathinfo($subfile, PATHINFO_FILENAME);

        // Match $order for subfiles
        $subfileContents = file_get_contents($subfile);
        preg_match('/\$order\s*=\s*"(.*?)";/', $subfileContents, $subfileOrderMatches);
        $subfileOrder = $subfileOrderMatches[1] ?? null;

        // Remove hyphens and add colon after the main part of the title
        $subfileTitle = str_replace('-', ' ', $subfileTitle);

        // Separate the main part (before the colon) and the rest of the title
        $parts = explode(' ', $subfileTitle, 2); // Split into two parts: main and description
        $mainPart = $parts[0]; // This is the first word (e.g., "Aristotele")
        $description = isset($parts[1]) ? $parts[1] : ''; // Everything after the first space (e.g., "l etica")

        // Combine the main part with colon and the description
        $formattedTitle = ucfirst($mainPart) . ": " . $description;

        $subfileLink = "$root/$menupath/{$filename}/{$subfileName}";
        echo "<li style=\"order:$subfileOrder\"><a href=\"{$subfileLink}\">{$formattedTitle}</a></li>";
      }
      echo "</ul>"; // End sublist
    }
  }
  // End the list item for the menu
  echo "</li>\n";
}
?>

That you can call in a place of the whole menu with a code like this:

 $menupath="your/relative-path";
 include "menu-automatic.inc"; 

Where menu-automatic.inc is the name of the file containing the above code.

Automatic images gallery

With flickity and php you can realize an automatic images gallery, with automatic titles and (if they are present) metatags:

<div id="gallery" style="width: 50%; margin-left: auto; margin-right: auto; margin-bottom: 4%;">
<div class="carousel" title="cliccare su una immagine per ingrandirla" data-flickity='{ "cellAlign": "center", "contain": true, "fullscreen": true, "wrapAround": true, "lazyLoad": 1 }'>

<?php

$images = glob("your-images-path/*.jpg");
$flag=1;

foreach($images as $image)
{
  // Ricava il titolo dell'immagine (metatag o nome del file)
  $imagedescription = '';
  if (function_exists('exif_read_data')) {
    $exifData = exif_read_data($image);

    // Controlla se esiste un campo di commento o descrizione
    if (isset($exifData['ImageDescription'])) {
      $imagedescription = $exifData['ImageDescription']; // Titolo o descrizione nell'EXIF
    }
  }

  $imageTitle = '';

  // Verifica se la funzione IPTC è disponibile
  if (function_exists('iptcparse')) {
    // Ottieni i metadati IPTC dall'immagine
    $iptcData = iptcparse(@iptcembed('', $image)); // iptcembed recupera i metadati IPTC da un'immagine

    // Controlla se il campo "headline" (titolo) è presente nei metadati IPTC
    if (isset($iptcData[2])) {
      $imageTitle = $iptcData[2][0]; // Il campo 2 è "headline" nell'IPTC
      // Troncamento del titolo se troppo lungo
      $maxLength = 50; // Lunghezza massima del titolo
      if (strlen($imageTitle) > $maxLength) {
        $imageTitle = substr($imageTitle, 0, $maxLength) . '...';
      }
    }
  }

  // Se non c'è un titolo IPTC, usa il nome del file senza trattini
  if (empty($imageTitle)) {
    $imageTitle = pathinfo($image, PATHINFO_FILENAME); // Ottieni il nome del file senza estensione

    // Rimuovi trattini dal nome del file, se presenti
    $imageTitle = str_replace('-', ' ', $imageTitle);
  }


  echo '<div class="carousel-cell' .($flag?' active':''). '">';
  echo '<img title="'. $imagedescription .'" data-flickity-lazyload="'. $image .'" onclick="onClick(this)" />';
  echo "<span class='carusel-image-title'>$imageTitle</span>";
  echo '</div>';
  $flag=0;
}
?>

</div>
</div>