switched from sass to pyScss library
This commit is contained in:
+18
-19
@@ -19,7 +19,7 @@ import json
|
||||
# import git
|
||||
# from pygit2 import Repository
|
||||
|
||||
from . import server, sasscompiler, md2html
|
||||
from . import server, scsscompiler, md2html
|
||||
|
||||
# ______
|
||||
# / ____/___ ________
|
||||
@@ -56,7 +56,7 @@ class Core():
|
||||
|
||||
def initDeamons(self):
|
||||
self.server = server.Server(self)
|
||||
self.sasscompiler = sasscompiler.Compiler(self)
|
||||
self.scsscompiler = scsscompiler.Compiler(self)
|
||||
self.contentcompiler = md2html.Compiler(self)
|
||||
|
||||
@property
|
||||
@@ -125,9 +125,9 @@ class Core():
|
||||
|
||||
def updateScss(self, reload=True):
|
||||
# print(self.docsettings)
|
||||
sassfilepath = os.path.join(self.cwd,'assets/css/setup.scss')
|
||||
# print(sassfilepath)
|
||||
sass = open(sassfilepath,"r").read()
|
||||
scssfilepath = os.path.join(self.cwd,'assets/css/setup.scss')
|
||||
# print(scssfilepath)
|
||||
scss = open(scssfilepath,"r").read()
|
||||
sets = {
|
||||
'pw':'page-width',
|
||||
'ph':'page-height',
|
||||
@@ -142,34 +142,34 @@ class Core():
|
||||
'lh':'line-height'
|
||||
}
|
||||
for s in sets:
|
||||
sass = re.sub(
|
||||
scss = re.sub(
|
||||
r'\$'+sets[s]+':\smm2pt\([0-9|\.]+\);',
|
||||
'$'+sets[s]+': mm2pt('+self.docsettings[s]+');',
|
||||
sass)
|
||||
scss)
|
||||
|
||||
# $col-number: 9;
|
||||
sass = re.sub(
|
||||
scss = re.sub(
|
||||
r'\$col-number:\s[0-9|\.]+;',
|
||||
'$col-number: '+self.docsettings['cn']+';',
|
||||
sass)
|
||||
scss)
|
||||
# $row-number: 12;
|
||||
sass = re.sub(
|
||||
scss = re.sub(
|
||||
r'\$row-number:\s[0-9|\.]+;',
|
||||
'$row-number: '+self.docsettings['rn']+';',
|
||||
sass)
|
||||
scss)
|
||||
#$header-odd: "Libriis, default header";
|
||||
sass = re.sub(
|
||||
scss = re.sub(
|
||||
r'\$header-odd:\s".+";',
|
||||
'$header-odd: "'+self.docsettings['ho']+'";',
|
||||
sass)
|
||||
scss)
|
||||
# $header-even: "Libriis, default header";
|
||||
sass = re.sub(
|
||||
scss = re.sub(
|
||||
r'\$header-even:\s".+";',
|
||||
'$header-even: "'+self.docsettings['he']+'";',
|
||||
sass)
|
||||
scss)
|
||||
|
||||
# print('sass', sass)
|
||||
open(sassfilepath,"w").write(sass)
|
||||
# print('scss', scss)
|
||||
open(scssfilepath,"w").write(scss)
|
||||
|
||||
if reload:
|
||||
self._mw.designstack.webkitview.reload()
|
||||
@@ -186,7 +186,6 @@ class Core():
|
||||
'nb_page='+str(self.docsettings['np'])+';',
|
||||
js)
|
||||
|
||||
# print('sass', sass)
|
||||
open(jsfilepath,"w").write(js)
|
||||
|
||||
if reload:
|
||||
@@ -245,7 +244,7 @@ class Core():
|
||||
if not cwd == self.cwd:
|
||||
self.cwd = cwd
|
||||
self.server.reload()
|
||||
self.sasscompiler.reload()
|
||||
self.scsscompiler.reload()
|
||||
self.contentcompiler.reload()
|
||||
|
||||
if not self.tempcwd:
|
||||
|
||||
@@ -392,7 +392,7 @@ class Editor(QWidget):
|
||||
# Initialize tab screen
|
||||
self.tabs = QTabWidget()
|
||||
|
||||
self.scsstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/css/styles.scss', "sass")
|
||||
self.scsstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/css/styles.scss', "scss")
|
||||
self.jstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/js/script.js', 'js')
|
||||
|
||||
# Add tabs
|
||||
|
||||
@@ -348,6 +348,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.mainstack.setCurrentIndex(self.core.mw_curstack)
|
||||
|
||||
# TODO: add an app console window (show sass compilation errors for example)
|
||||
# TODO: add an app console window (show scss compilation errors for example)
|
||||
|
||||
self.setCentralWidget(self.mainstack)
|
||||
|
||||
@@ -70,7 +70,9 @@ class Compiler():
|
||||
# get story div
|
||||
story_dom = template_dom.find('div', {"id":"flow-main"})
|
||||
|
||||
# page index
|
||||
pi = 0
|
||||
# loop through pages following summary (pages liste)
|
||||
for p in self.sum:
|
||||
# print(toc[p])
|
||||
pagename = p['title']
|
||||
@@ -84,14 +86,13 @@ class Compiler():
|
||||
continue
|
||||
# print('in_f : '+in_f)
|
||||
|
||||
pdoc_args = ['--mathjax',
|
||||
'--smart']
|
||||
pdoc_args = ['--mathjax']
|
||||
|
||||
pdoc_filters = []
|
||||
|
||||
output = pypandoc.convert_file(in_f,
|
||||
to='html5',
|
||||
format='markdown+header_attributes+link_attributes+bracketed_spans',
|
||||
format='markdown+smart+header_attributes+link_attributes+bracketed_spans',
|
||||
extra_args=pdoc_args,
|
||||
filters=pdoc_filters)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 30-05-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: sasscompiler.py
|
||||
# @Filename: scsscompiler.py
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 03-06-2017
|
||||
# @License: GPL-V3
|
||||
@@ -13,7 +13,7 @@ from __future__ import absolute_import, print_function, division, unicode_litera
|
||||
|
||||
import os
|
||||
from PyQt5.QtCore import QFileSystemWatcher
|
||||
import sass
|
||||
import scss
|
||||
|
||||
class Compiler():
|
||||
def __init__(self,parent):
|
||||
@@ -30,16 +30,21 @@ class Compiler():
|
||||
self.fs_watcher.fileChanged.connect(self.compile_scss)
|
||||
|
||||
def compile_scss(self):
|
||||
print("compiling sass")
|
||||
print("compiling scss")
|
||||
try:
|
||||
scss = sass.compile_file(str.encode(os.path.join(self.parent.cwd,'assets/css/main.scss')))
|
||||
import_path = ['./assets/css/']
|
||||
print("import path",import_path)
|
||||
comp = scss.Compiler(output_style="compressed", search_path=import_path)
|
||||
# Compiler().compile_string("a { color: red + green; }")
|
||||
scss_file = open(os.path.join(self.parent.cwd,'assets/css/main.scss'),"r")
|
||||
css = comp.compile_string(scss_file.read())
|
||||
# print("css : %s" % css)
|
||||
with open(os.path.join(self.parent.cwd,'assets/css/main.css'), 'w') as fp:
|
||||
fp.write(scss.decode('utf8'))
|
||||
fp.write(css)
|
||||
except Exception as e:
|
||||
print("Error compiling Sass", e)
|
||||
print("Error compiling scss", e)
|
||||
pass
|
||||
|
||||
|
||||
def refreshPaths(self):
|
||||
self.paths = [
|
||||
os.path.join(self.parent.cwd,'assets'),
|
||||
@@ -51,7 +56,7 @@ class Compiler():
|
||||
self.paths.append(os.path.join(self.parent.cwd,'assets/css',f))
|
||||
|
||||
def reload(self):
|
||||
print('Reload sass compiler')
|
||||
print('Reload scss compiler')
|
||||
self.fs_watcher.removePaths(self.paths)
|
||||
self.refreshPaths()
|
||||
print('paths', self.paths)
|
||||
@@ -43,7 +43,7 @@ you'll have to build qt-webkit from source : https://github.com/annulen/webkit/w
|
||||
#### dependences
|
||||
```shell
|
||||
apt-get install qt5-base pandoc python3 python3-pyqt5 python3-pip
|
||||
pip3 install sass markdown beautifulsoup4 pypandoc pygments setuptools pyphen
|
||||
pip3 install pyScss markdown beautifulsoup4 pypandoc pygments setuptools pyphen
|
||||
```
|
||||
#### Libriis
|
||||
clone
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
sass
|
||||
pyScss
|
||||
pyphen
|
||||
pygments-style-github
|
||||
|
||||
Reference in New Issue
Block a user