HGustavs / LenaSYS

Code Viewer and Course Organization System used in some courses at University of Skövde
57 stars 31 forks source link

Plus sign (+) not displayed correctly when viewing markdown file in file editor #11491

Closed a97marbr closed 2 years ago

a97marbr commented 2 years ago

Plus sign (+) not displayed correctly when viewing markdown file in file editor, i.e., pressing the link to the file in the file editor.

Code such as this:

~~~
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
~~~

Will display the HTML code &#43; rather than the plus sign (+)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="10dp">

    <TextView
        android:id="@&#43;id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18sp"/>

</LinearLayout>

In the mardown editor (pen icon) the rendering is correct.
b20jonlu commented 2 years ago

@a97marbr Can you describe what steps you took to get this issue and which files you used? I can get a similar issue when i open a text file in the file editor, type a plus sign, save it and open it again. The difference is that instead of the html element i get %2B which is the hexadecimal representation of 43. When i changed %2b to &#43 in fileed.js line 771 the plus sign rendered correct in the markdown but was saved as the html code. If you could clarify your own steps that would be helpful, thanks.

function saveMarkdown() {
    let content = document.getElementById("mrkdwntxt").value;
    content = content.replace(/\+/g, '%2B');
    AJAXService("SAVEFILE", {
        cid: querystring['courseid'],
        contents: content,
        filename: filename,
        filepath: filepath,
        kind: filekind
    }, "FILE");
    document.getElementById("mrkdwntxt").innerHTML = "";
    $(".previewWindow").hide();
    $(".previewWindowContainer").css("display", "none");
}
a97marbr commented 2 years ago

Create a markdown file, for example, markdown_with_plus.md, in your favorite text editor. Insert the following markdown code that I provided in the original issue.

~~~
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
~~~

Save the file and upload it to a course on your LenaSYS installation. Now when you try to view this file in the filled service you will not see the plus sign but rather &#43;, which is the HTML code for a plus sign

c20adael commented 2 years ago

This has been merged and will be closed.