miguelgrinberg / Flask-PageDown

Implementation of StackOverflow's "PageDown" markdown editor for Flask and Flask-WTF.
MIT License
244 stars 21 forks source link

form is showing html code as text in page #25

Closed umair313 closed 3 years ago

umair313 commented 4 years ago

I am seeing this in page

<div class="flask-pagedown">
<textarea class="flask-pagedown-input" id="flask-pagedown-pagedown" name="pagedown" rows="10">
  </textarea>
&lt;/div&gt;

please tell me how to fix it

miguelgrinberg commented 4 years ago

You need to show the code. This is just telling me that your HTML is being escaped, for some reason. Without the code it is hard to imagine why this would happen.

umair313 commented 4 years ago

@miguelgrinberg here is code


app.py

from flask import Flask , render_template
from flask_pagedown import PageDown
from project.forms import PageDownFormExample

app = Flask(__name__)
app.config['SECRET_KEY'] = '28ff088dd9770dde26d9cd00ee6897e1' 
pagedwon=PageDown(app)

@app.route('/', methods = ['GET', 'POST'])
def index():
   form = PageDownFormExample()
   if form.validate_on_submit():
      text = form.pagedown.data
      # do something interesting with the Markdown text
   return render_template('test.html', form = form)

if __name__ == '__main__':
   app.run(debug = True)

forms.py

from flask_wtf import Form
from flask_pagedown.fields import PageDownField
from wtforms.fields import SubmitField

class PageDownFormExample(Form):
    pagedown = PageDownField('Enter your markdown')
    submit = SubmitField('Submit')

test.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    {{ pagedown.include_pagedown() }}
</head>
<body>
    <form method="POST">
        <form method="POST">
            {{ form.pagedown(only_preview=True) }}
            {{ form.pagedown(only_input=True, rows=10) }}
            {{ form.submit }}
        </form>
    </form>
</body>
</html>
miguelgrinberg commented 4 years ago

Are you using the most up to date version of the Flask-Markdown extension? Please include the output of pip freeze to confirm.

umair313 commented 4 years ago

Are you using the most up to date version of the Flask-Markdown extension? Please include the output of pip freeze to confirm.

here is the output of the pip freeze

aniso8601==1.3.0
astroid==2.4.2
bcrypt==3.2.0
blinker==1.4
cffi==1.14.3
click==7.1.2
colorama==0.4.4
dnspython==2.0.0
email-validator==1.1.1
Flask==1.1.2
Flask-Bcrypt==0.7.1
Flask-Login==0.5.0
Flask-Mail==0.9.1
Flask-PageDown==0.2.2
Flask-RESTful==0.3.6
Flask-Markdown==0.3
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
idna==2.10
isort==5.6.3
itsdangerous==1.1.0
Jinja2==2.11.2
lazy-object-proxy==1.4.3
Markdown==2.6.9
MarkupSafe==1.1.1
mccabe==0.6.1
Pillow==8.0.1
pycparser==2.20
pylint==2.6.0
python-dateutil==2.6.1
python-dotenv==0.14.0
pytz==2017.2
six==1.15.0
SQLAlchemy==1.3.20
toml==0.10.1
Werkzeug==1.0.1
wrapt==1.12.1
WTForms==2.3.3
miguelgrinberg commented 4 years ago

Yeah, you are on an old release. Try pip install --upgrade flask-pagedown.

umair313 commented 4 years ago

oh yeah fixed... thank a lot... i wanna ask one more thing that I saw options for bold , italic , code , image on top of textarea field by using flask_pagedown but I am not seeing this in here..... here in this project A-Simple-Note-Taking-Web-App https://github.com/umair313/A-Simple-Note-Taking-Web-App

On Wed, Nov 4, 2020 at 12:16 AM Miguel Grinberg notifications@github.com wrote:

Yeah, you are on an old release. Try pip install --upgrade flask-pagedown.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/miguelgrinberg/Flask-PageDown/issues/25#issuecomment-721324908, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBDRBM57UYNMMUY2RGE5I3SOBJKLANCNFSM4TIL4YUQ .

miguelgrinberg commented 4 years ago

@umair313 this extension implements the "Converter" part of PageDown. The "Editor" portion is the one that has the buttons, and it is currently not implemented, but you can add it directly in your template, as it is a JavaScript library.

umair313 commented 3 years ago

Thank you can you provide any link for that library.

miguelgrinberg commented 3 years ago

https://github.com/StackExchange/pagedown