mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Add CommonMark in ChatLobbyDialog
This commit is contained in:
parent
82c9084ca4
commit
d03ee1c0b0
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "cmark"]
|
||||
path = supportlibs/cmark
|
||||
url = https://github.com/commonmark/cmark.git
|
@ -85,6 +85,7 @@ environment:
|
||||
# - cmd: echo This is batch again
|
||||
# - cmd: set MY_VAR=12345
|
||||
install:
|
||||
- git submodule update --init
|
||||
# Configuring MSys2
|
||||
- set PATH=C:\msys64\usr\bin;%PATH%
|
||||
- set PATH=C:\msys64\mingw32\bin;%PATH%
|
||||
|
42
retroshare-gui/src/cmark_export.h
Normal file
42
retroshare-gui/src/cmark_export.h
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef CMARK_EXPORT_H
|
||||
#define CMARK_EXPORT_H
|
||||
|
||||
#ifdef CMARK_STATIC_DEFINE
|
||||
# define CMARK_EXPORT
|
||||
# define CMARK_NO_EXPORT
|
||||
#else
|
||||
# ifndef CMARK_EXPORT
|
||||
# ifdef libcmark_EXPORTS
|
||||
/* We are building this library */
|
||||
# define CMARK_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define CMARK_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef CMARK_NO_EXPORT
|
||||
# define CMARK_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CMARK_DEPRECATED
|
||||
# define CMARK_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef CMARK_DEPRECATED_EXPORT
|
||||
# define CMARK_DEPRECATED_EXPORT CMARK_EXPORT CMARK_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef CMARK_DEPRECATED_NO_EXPORT
|
||||
# define CMARK_DEPRECATED_NO_EXPORT CMARK_NO_EXPORT CMARK_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef CMARK_NO_DEPRECATED
|
||||
# define CMARK_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
7
retroshare-gui/src/cmark_version.h
Normal file
7
retroshare-gui/src/cmark_version.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef CMARK_VERSION_H
|
||||
#define CMARK_VERSION_H
|
||||
|
||||
#define CMARK_VERSION ((0 << 16) | (28 << 8) | 0)
|
||||
#define CMARK_VERSION_STRING "0.28.0"
|
||||
|
||||
#endif
|
76
retroshare-gui/src/config.h
Normal file
76
retroshare-gui/src/config.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef CMARK_CONFIG_H
|
||||
#define CMARK_CONFIG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HAVE_STDBOOL_H
|
||||
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
#include <stdbool.h>
|
||||
#elif !defined(__cplusplus)
|
||||
typedef char bool;
|
||||
#endif
|
||||
|
||||
#define HAVE___BUILTIN_EXPECT
|
||||
|
||||
#define HAVE___ATTRIBUTE__
|
||||
|
||||
#ifdef HAVE___ATTRIBUTE__
|
||||
#define CMARK_ATTRIBUTE(list) __attribute__ (list)
|
||||
#else
|
||||
#define CMARK_ATTRIBUTE(list)
|
||||
#endif
|
||||
|
||||
#ifndef CMARK_INLINE
|
||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
||||
#define CMARK_INLINE __inline
|
||||
#else
|
||||
#define CMARK_INLINE inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* snprintf and vsnprintf fallbacks for MSVC before 2015,
|
||||
due to Valentin Milea http://stackoverflow.com/questions/2915672/
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define snprintf c99_snprintf
|
||||
#define vsnprintf c99_vsnprintf
|
||||
|
||||
CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
if (size != 0)
|
||||
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
||||
if (count == -1)
|
||||
count = _vscprintf(format, ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
|
||||
{
|
||||
int count;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
count = c99_vsnprintf(outBuf, size, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -28,7 +28,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "gui/elastic/node.h"
|
||||
#include "gui/elastic/elnode.h"
|
||||
|
||||
/********
|
||||
* #define DEBUG_NETWORKVIEW
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "gui/FriendsDialog.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/chat/ChatWidget.h"
|
||||
#include "gui/common/html.h"
|
||||
#include "gui/common/rshtml.h"
|
||||
#include "gui/common/FriendSelectionDialog.h"
|
||||
#include "gui/common/RSTreeWidgetItem.h"
|
||||
#include "gui/gxs/GxsIdChooser.h"
|
||||
|
@ -72,8 +72,15 @@
|
||||
* #define CHAT_DEBUG 1
|
||||
*****/
|
||||
|
||||
ChatWidget::ChatWidget(QWidget *parent) :
|
||||
QWidget(parent), sendingBlocked(false), ui(new Ui::ChatWidget)
|
||||
ChatWidget::ChatWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, completionPosition(0), newMessages(false), typing(false), peerStatus(0)
|
||||
, sendingBlocked(false), useCMark(false)
|
||||
, lastStatusSendTime(0)
|
||||
, firstShow(true), inChatCharFormatChanged(false), firstSearch(true)
|
||||
, lastUpdateCursorPos(0), lastUpdateCursorEnd(0)
|
||||
, completer(NULL), notify(NULL)
|
||||
, ui(new Ui::ChatWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -84,17 +91,8 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||
int butt_size(iconSize.height() + fmm);
|
||||
QSize buttonSize = QSize(butt_size, butt_size);
|
||||
|
||||
newMessages = false;
|
||||
typing = false;
|
||||
peerStatus = 0;
|
||||
firstShow = true;
|
||||
firstSearch = true;
|
||||
inChatCharFormatChanged = false;
|
||||
completer = NULL;
|
||||
lastMsgDate = QDate::currentDate();
|
||||
|
||||
lastStatusSendTime = 0 ;
|
||||
|
||||
//Resize Tool buttons
|
||||
ui->emoteiconButton->setFixedSize(buttonSize);
|
||||
ui->emoteiconButton->setIconSize(iconSize);
|
||||
@ -144,7 +142,6 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||
connect(ui->actionSearchWithoutLimit, SIGNAL(triggered()), this, SLOT(toogle_SeachWithoutLimit()));
|
||||
connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint)));
|
||||
|
||||
notify=NULL;
|
||||
ui->notifyButton->setVisible(false);
|
||||
|
||||
ui->markButton->setToolTip(tr("<b>Mark this selected text</b><br><i>Ctrl+M</i>"));
|
||||
@ -194,6 +191,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||
fontmenu->addAction(ui->actionResetFont);
|
||||
fontmenu->addAction(ui->actionNoEmbed);
|
||||
fontmenu->addAction(ui->actionSendAsPlainText);
|
||||
fontmenu->addAction(ui->actionSend_as_CommonMark);
|
||||
|
||||
QMenu *menu = new QMenu();
|
||||
menu->addAction(ui->actionClearChatHistory);
|
||||
@ -207,6 +205,10 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||
ui->chatTextEdit->setOnlyPlainText(ui->actionSendAsPlainText->isChecked());
|
||||
connect(ui->actionSendAsPlainText, SIGNAL(toggled(bool)), ui->chatTextEdit, SLOT(setOnlyPlainText(bool)) );
|
||||
|
||||
connect(ui->actionSend_as_CommonMark, SIGNAL(toggled(bool)), this, SLOT(setUseCMark(bool)) );
|
||||
ui->cmPreview->setVisible(false);
|
||||
connect(ui->chatTextEdit, SIGNAL(textChanged()), this, SLOT(updateCMPreview()) );
|
||||
|
||||
ui->textBrowser->resetImagesStatus(Settings->getChatLoadEmbeddedImages());
|
||||
ui->textBrowser->installEventFilter(this);
|
||||
ui->textBrowser->viewport()->installEventFilter(this);
|
||||
@ -981,6 +983,11 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
|
||||
}
|
||||
|
||||
//Use CommonMark
|
||||
if (message.contains("CMark=\"true\"")) {
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_USE_CMARK;
|
||||
}
|
||||
|
||||
// Always fix colors
|
||||
formatTextFlag |= RSHTML_FORMATTEXT_FIX_COLORS;
|
||||
qreal desiredContrast = Settings->valueFromGroup("Chat", "MinimumContrast", 4.5).toDouble();
|
||||
@ -1229,7 +1236,9 @@ void ChatWidget::sendChat()
|
||||
text = chatWidget->toPlainText();
|
||||
text.replace(QChar(-4),"");//Char used when image on text.
|
||||
} else {
|
||||
RsHtml::optimizeHtml(chatWidget, text, (ui->actionNoEmbed->isChecked() ? RSHTML_FORMATTEXT_NO_EMBED : 0));
|
||||
RsHtml::optimizeHtml(chatWidget, text,
|
||||
(ui->actionNoEmbed->isChecked() ? RSHTML_FORMATTEXT_NO_EMBED : 0)
|
||||
+ (ui->actionSend_as_CommonMark->isChecked() ? RSHTML_FORMATTEXT_USE_CMARK : 0) );
|
||||
}
|
||||
std::string msg = text.toUtf8().constData();
|
||||
|
||||
@ -1823,6 +1832,22 @@ bool ChatWidget::setStyle()
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatWidget::setUseCMark(const bool bUseCMark)
|
||||
{
|
||||
useCMark = bUseCMark;
|
||||
ui->cmPreview->setVisible(useCMark);
|
||||
updateCMPreview();
|
||||
}
|
||||
|
||||
void ChatWidget::updateCMPreview()
|
||||
{
|
||||
if (!useCMark) return;
|
||||
|
||||
QString message = ui->chatTextEdit->toHtml();
|
||||
QString formattedMessage = RsHtml().formatText(ui->cmPreview->document(), message, RSHTML_FORMATTEXT_USE_CMARK);
|
||||
ui->cmPreview->setHtml(formattedMessage);
|
||||
}
|
||||
|
||||
void ChatWidget::quote()
|
||||
{
|
||||
QString text = ui->textBrowser->textCursor().selection().toPlainText();
|
||||
|
@ -128,6 +128,8 @@ public:
|
||||
|
||||
public slots:
|
||||
void updateStatus(const QString &peer_id, int status);
|
||||
void setUseCMark(const bool bUseCMark);
|
||||
void updateCMPreview();
|
||||
|
||||
private slots:
|
||||
//void pasteCreateMsgLink() ;
|
||||
@ -222,7 +224,8 @@ private:
|
||||
bool typing;
|
||||
int peerStatus;
|
||||
|
||||
bool sendingBlocked;
|
||||
bool sendingBlocked;
|
||||
bool useCMark;
|
||||
|
||||
time_t lastStatusSendTime;
|
||||
|
||||
|
@ -268,22 +268,34 @@ border-image: url(:/images/closepressed.png)
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="MimeTextEdit" name="chatTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QSplitter" name="chatTextEditHSplitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
<property name="handleWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="placeholderText" stdset="0">
|
||||
<string>Type a message here</string>
|
||||
<property name="childrenCollapsible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="MimeTextEdit" name="chatTextEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText" stdset="0">
|
||||
<string>Type a message here</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="RSTextBrowser" name="cmPreview"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -915,6 +927,21 @@ border-image: url(:/images/closepressed.png)
|
||||
<string>Show Hidden Images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSend_as_CommonMark">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/markdown-mark.png</normaloff>:/icons/png/markdown-mark.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Send as CommonMark</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Text will be formatted using CommonMark.</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@ -945,8 +972,8 @@ border-image: url(:/images/closepressed.png)
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -21,12 +21,12 @@
|
||||
****************************************************************/
|
||||
|
||||
/*
|
||||
** \file html.cpp
|
||||
** \version $Id: html.cpp 2362 2008-02-29 04:30:11Z edmanm $
|
||||
** \file rshtml.cpp
|
||||
** \version $Id: rshtml.cpp 2362 2008-02-29 04:30:11Z edmanm $
|
||||
** \brief HTML formatting functions
|
||||
*/
|
||||
|
||||
#include "html.h"
|
||||
#include "rshtml.h"
|
||||
|
||||
|
||||
/** Wraps a string in "<p>" tags, converts "\n" to "<br>" and converts "\n\n"
|
@ -21,8 +21,8 @@
|
||||
****************************************************************/
|
||||
|
||||
/*
|
||||
** \file html.h
|
||||
** \version $Id: html.h 2362 2008-02-29 04:30:11Z edmanm $
|
||||
** \file rshtml.h
|
||||
** \version $Id: rshtml.h 2362 2008-02-29 04:30:11Z edmanm $
|
||||
** \brief HTML formatting functions
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@
|
||||
** \brief Provides a custom Vidalia mesage box
|
||||
*/
|
||||
|
||||
#include "html.h"
|
||||
#include "rshtml.h"
|
||||
#include "vmessagebox.h"
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "arrow.h"
|
||||
#include "node.h"
|
||||
#include "elnode.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "elnode.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "elnode.h"
|
||||
#include "graphwidget.h"
|
||||
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
@ -39,8 +39,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef NODE_H
|
||||
#define NODE_H
|
||||
#ifndef ELNODE_H
|
||||
#define ELNODE_H
|
||||
|
||||
#include <QApplication>
|
||||
#if QT_VERSION >= 0x040600
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "graphwidget.h"
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "elnode.h"
|
||||
#include "fft.h"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <QFile>
|
||||
#include <QDesktopServices>
|
||||
#include "gui/common/vmessagebox.h"
|
||||
#include "gui/common/html.h"
|
||||
#include "gui/common/rshtml.h"
|
||||
#include <rshare.h>
|
||||
|
||||
#include "helptextbrowser.h"
|
||||
|
@ -241,5 +241,6 @@
|
||||
<file>icons/warning_yellow_128.png</file>
|
||||
<file>icons/yahoo.png</file>
|
||||
<file>icons/yandex.png</file>
|
||||
<file>icons/png/markdown-mark.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
retroshare-gui/src/gui/icons/png/markdown-mark.png
Normal file
BIN
retroshare-gui/src/gui/icons/png/markdown-mark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
@ -2,7 +2,7 @@
|
||||
|
||||
TEMPLATE = app
|
||||
QT += network xml
|
||||
CONFIG += qt gui uic qrc resources idle
|
||||
CONFIG += qt gui uic qrc resources idle cmark
|
||||
CONFIG += console
|
||||
TARGET = retroshare
|
||||
DEFINES += TARGET=\\\"$${TARGET}\\\"
|
||||
@ -478,7 +478,7 @@ HEADERS += rshare.h \
|
||||
gui/common/RsUrlHandler.h \
|
||||
gui/common/RsCollectionDialog.h \
|
||||
gui/common/rwindow.h \
|
||||
gui/common/html.h \
|
||||
gui/common/rshtml.h \
|
||||
gui/common/AvatarDefs.h \
|
||||
gui/common/GroupFlagsWidget.h \
|
||||
gui/common/GroupSelectionBox.h \
|
||||
@ -546,7 +546,7 @@ HEADERS += rshare.h \
|
||||
gui/elastic/graphwidget.h \
|
||||
gui/elastic/edge.h \
|
||||
gui/elastic/arrow.h \
|
||||
gui/elastic/node.h \
|
||||
gui/elastic/elnode.h \
|
||||
gui/NewsFeed.h \
|
||||
gui/feeds/FeedItem.h \
|
||||
gui/feeds/FeedHolder.h \
|
||||
@ -796,7 +796,7 @@ SOURCES += main.cpp \
|
||||
gui/common/RsCollectionDialog.cpp \
|
||||
gui/common/RsUrlHandler.cpp \
|
||||
gui/common/rwindow.cpp \
|
||||
gui/common/html.cpp \
|
||||
gui/common/rshtml.cpp \
|
||||
gui/common/AvatarDefs.cpp \
|
||||
gui/common/AvatarDialog.cpp \
|
||||
gui/common/GroupFlagsWidget.cpp \
|
||||
@ -897,7 +897,7 @@ SOURCES += main.cpp \
|
||||
gui/elastic/graphwidget.cpp \
|
||||
gui/elastic/edge.cpp \
|
||||
gui/elastic/arrow.cpp \
|
||||
gui/elastic/node.cpp \
|
||||
gui/elastic/elnode.cpp \
|
||||
gui/NewsFeed.cpp \
|
||||
gui/feeds/FeedItem.cpp \
|
||||
gui/feeds/FeedHolder.cpp \
|
||||
@ -1369,3 +1369,43 @@ gxsgui {
|
||||
|
||||
|
||||
}
|
||||
|
||||
cmark {
|
||||
|
||||
HEADERS += \
|
||||
../../supportlibs/cmark/src/buffer.h \
|
||||
../../supportlibs/cmark/src/chunk.h \
|
||||
../../supportlibs/cmark/src/cmark.h \
|
||||
../../supportlibs/cmark/src/cmark_ctype.h \
|
||||
../../supportlibs/cmark/src/houdini.h \
|
||||
../../supportlibs/cmark/src/inlines.h \
|
||||
../../supportlibs/cmark/src/iterator.h \
|
||||
../../supportlibs/cmark/src/node.h \
|
||||
../../supportlibs/cmark/src/parser.h \
|
||||
../../supportlibs/cmark/src/references.h \
|
||||
../../supportlibs/cmark/src/render.h \
|
||||
../../supportlibs/cmark/src/scanners.h \
|
||||
../../supportlibs/cmark/src/utf8.h \
|
||||
|
||||
SOURCES += \
|
||||
../../supportlibs/cmark/src/blocks.c \
|
||||
../../supportlibs/cmark/src/buffer.c \
|
||||
../../supportlibs/cmark/src/cmark.c \
|
||||
../../supportlibs/cmark/src/cmark_ctype.c \
|
||||
../../supportlibs/cmark/src/commonmark.c \
|
||||
../../supportlibs/cmark/src/houdini_href_e.c \
|
||||
../../supportlibs/cmark/src/houdini_html_e.c \
|
||||
../../supportlibs/cmark/src/houdini_html_u.c \
|
||||
../../supportlibs/cmark/src/html.c \
|
||||
../../supportlibs/cmark/src/inlines.c \
|
||||
../../supportlibs/cmark/src/iterator.c \
|
||||
../../supportlibs/cmark/src/latex.c \
|
||||
../../supportlibs/cmark/src/man.c \
|
||||
../../supportlibs/cmark/src/node.c \
|
||||
../../supportlibs/cmark/src/references.c \
|
||||
../../supportlibs/cmark/src/render.c \
|
||||
../../supportlibs/cmark/src/scanners.c \
|
||||
../../supportlibs/cmark/src/utf8.c \
|
||||
../../supportlibs/cmark/src/xml.c \
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gui/common/html.h>
|
||||
#include <gui/common/rshtml.h>
|
||||
#include <gui/common/vmessagebox.h>
|
||||
#include <gui/gxs/GxsIdDetails.h>
|
||||
#include <gui/settings/rsharesettings.h>
|
||||
|
@ -38,6 +38,10 @@
|
||||
#include "util/imageutil.h"
|
||||
#include "util/rstime.h"
|
||||
|
||||
//Include for CMark
|
||||
#include <gui/../../../supportlibs/cmark/src/cmark.h>
|
||||
#include <gui/../../../supportlibs/cmark/src/node.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
@ -582,6 +586,29 @@ QString RsHtml::formatText(QTextDocument *textDocument, const QString &text, ulo
|
||||
// Save Space and Tab because doc loose it.
|
||||
formattedText=saveSpace(formattedText);
|
||||
|
||||
if (flag & RSHTML_FORMATTEXT_USE_CMARK) {
|
||||
// Transform html to plain text
|
||||
QTextBrowser textBrowser;
|
||||
textBrowser.setHtml(text);
|
||||
formattedText = textBrowser.toPlainText();
|
||||
// Parse CommonMark
|
||||
int options = CMARK_OPT_DEFAULT;
|
||||
cmark_parser *parser = cmark_parser_new(options);
|
||||
cmark_parser_feed(parser, formattedText.toStdString().c_str(),formattedText.length());
|
||||
cmark_node *document = cmark_parser_finish(parser);
|
||||
cmark_parser_free(parser);
|
||||
char *result;
|
||||
result = cmark_render_html(document, options);
|
||||
// Get result as html
|
||||
formattedText = QString::fromUtf8(result);
|
||||
//Clean
|
||||
cmark_node_mem(document)->free(result);
|
||||
cmark_node_free(document);
|
||||
//Get document formed HTML
|
||||
textBrowser.setHtml(formattedText);
|
||||
formattedText=textBrowser.toHtml();
|
||||
}
|
||||
|
||||
QString errorMsg; int errorLine; int errorColumn;
|
||||
|
||||
QDomDocument doc;
|
||||
@ -981,6 +1008,12 @@ static void styleCreate(QDomDocument& doc
|
||||
noEmbedAttr.setValue("true");
|
||||
styleElem.attributes().setNamedItem(noEmbedAttr);
|
||||
}
|
||||
if (flag & RSHTML_FORMATTEXT_USE_CMARK) {
|
||||
QDomAttr cMarkAttr;
|
||||
cMarkAttr = doc.createAttribute("CMark");
|
||||
cMarkAttr.setValue("true");
|
||||
styleElem.attributes().setNamedItem(cMarkAttr);
|
||||
}
|
||||
}
|
||||
|
||||
while(styleElem.childNodes().count()>0) {
|
||||
|
@ -44,6 +44,7 @@
|
||||
#define RSHTML_FORMATTEXT_REMOVE_FONT (RSHTML_FORMATTEXT_REMOVE_FONT_WEIGHT | RSHTML_FORMATTEXT_REMOVE_FONT_STYLE | RSHTML_FORMATTEXT_REMOVE_FONT_FAMILY | RSHTML_FORMATTEXT_REMOVE_FONT_SIZE)
|
||||
#define RSHTML_FORMATTEXT_CLEANSTYLE (RSHTML_FORMATTEXT_REMOVE_FONT | RSHTML_FORMATTEXT_REMOVE_COLOR)
|
||||
#define RSHTML_FORMATTEXT_NO_EMBED 0x0400//1024
|
||||
#define RSHTML_FORMATTEXT_USE_CMARK 0x0800//2048
|
||||
/* Flags for RsHtml::optimizeHtml */
|
||||
#define RSHTML_OPTIMIZEHTML_MASK (RSHTML_FORMATTEXT_CLEANSTYLE | RSHTML_FORMATTEXT_FIX_COLORS | RSHTML_FORMATTEXT_OPTIMIZE)
|
||||
|
||||
|
1
supportlibs/cmark
Submodule
1
supportlibs/cmark
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d
|
Loading…
Reference in New Issue
Block a user