Check inside list for +, =, ' '
This commit is contained in:
parent
8d15f635b3
commit
066e89b684
|
@ -233,6 +233,9 @@ def check_article(post_uri,Force):
|
||||||
# Check links (anchors)
|
# Check links (anchors)
|
||||||
check_links_anchors(article)
|
check_links_anchors(article)
|
||||||
|
|
||||||
|
# Check titles/comments in article
|
||||||
|
check_lists_contents(article.rsplit('\n'))
|
||||||
|
|
||||||
# Check other markers
|
# Check other markers
|
||||||
check_article_markers(article)
|
check_article_markers(article)
|
||||||
|
|
||||||
|
@ -379,10 +382,6 @@ def check_post_header(headers):
|
||||||
if date:
|
if date:
|
||||||
check_date(date)
|
check_date(date)
|
||||||
|
|
||||||
#------------------------------
|
|
||||||
# Check valid Opitonal markers
|
|
||||||
#------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
#===================#
|
#===================#
|
||||||
# MANDATORY Markers #
|
# MANDATORY Markers #
|
||||||
|
@ -912,7 +911,6 @@ def check_links_anchors(article):
|
||||||
#for ln, line in enumerate(article.rsplit('\n'), 1):
|
#for ln, line in enumerate(article.rsplit('\n'), 1):
|
||||||
anchors_link = re.findall(r'\>_(.*?)_\<', article)
|
anchors_link = re.findall(r'\>_(.*?)_\<', article)
|
||||||
for anchor in anchors_link:
|
for anchor in anchors_link:
|
||||||
print('> Anchor found: %s'%(anchor))
|
|
||||||
anchor_id = anchor.rsplit(':',1)[0]
|
anchor_id = anchor.rsplit(':',1)[0]
|
||||||
if not re.search(r'\>\> %s'%anchor_id, article):
|
if not re.search(r'\>\> %s'%anchor_id, article):
|
||||||
msg_log = 'Unused anchor ID ">> %s" from link "%s"'%(
|
msg_log = 'Unused anchor ID ">> %s" from link "%s"'%(
|
||||||
|
@ -920,8 +918,29 @@ def check_links_anchors(article):
|
||||||
)
|
)
|
||||||
log.append_f(post_logs,msg_log,1)
|
log.append_f(post_logs,msg_log,1)
|
||||||
Post_Err = True
|
Post_Err = True
|
||||||
Post_Err = True
|
|
||||||
|
|
||||||
|
#====================================#
|
||||||
|
# Check inside list for only + and = #
|
||||||
|
# Multilines for one marker list #
|
||||||
|
# MUST have at leat one space (\s) #
|
||||||
|
#------------------------------------#
|
||||||
|
def check_lists_contents(article):
|
||||||
|
global Post_Err
|
||||||
|
|
||||||
|
inlist = False
|
||||||
|
|
||||||
|
for line in article:
|
||||||
|
|
||||||
|
if re.match(markers_reg[3][0], line):
|
||||||
|
inlist = True
|
||||||
|
continue
|
||||||
|
elif re.match(markers_reg[3][1], line):
|
||||||
|
inlist = False
|
||||||
|
|
||||||
|
if inlist and not re.match(r'^\+|^\=|\s', line):
|
||||||
|
msg_log = 'Content list not "+" or "=": %s'%line
|
||||||
|
log.append_f(post_logs,msg_log,1)
|
||||||
|
Post_Err = True
|
||||||
|
|
||||||
#====================================#
|
#====================================#
|
||||||
# Create Database file for this Post #
|
# Create Database file for this Post #
|
||||||
|
|
|
@ -69,7 +69,7 @@ def nowdate():
|
||||||
# Append line to specific log file #
|
# Append line to specific log file #
|
||||||
#----------------------------------#
|
#----------------------------------#
|
||||||
def append_f(f,line,n):
|
def append_f(f,line,n):
|
||||||
smiley = [':)',':(\033[1;31m','\033[1;33m:|']
|
smiley = [':D',':<\033[1;31m','\033[1;33m:|']
|
||||||
now = nowdate()
|
now = nowdate()
|
||||||
|
|
||||||
# Open file to append line
|
# Open file to append line
|
||||||
|
|
|
@ -70,6 +70,9 @@ def manage_wip(file_post, Force):
|
||||||
|
|
||||||
# All is good, converting...
|
# All is good, converting...
|
||||||
#---------------------------
|
#---------------------------
|
||||||
|
# Source DB variables
|
||||||
|
post_db = exec(open(check.curr_post_db).read(),globals())
|
||||||
|
|
||||||
# Send to log
|
# Send to log
|
||||||
msg_log = 'Wip > Article: %s. logs: %s'%(
|
msg_log = 'Wip > Article: %s. logs: %s'%(
|
||||||
check.post_uri, check.post_logs
|
check.post_uri, check.post_logs
|
||||||
|
@ -91,6 +94,10 @@ def manage_wip(file_post, Force):
|
||||||
wip_begin_markers(wip_html.rsplit('\n'))
|
wip_begin_markers(wip_html.rsplit('\n'))
|
||||||
wip_titles( wip_html.rsplit('\n'))
|
wip_titles( wip_html.rsplit('\n'))
|
||||||
wip_words_markers(wip_html)
|
wip_words_markers(wip_html)
|
||||||
|
wip_anchors( wip_html)
|
||||||
|
|
||||||
|
# After all, convert protected contents
|
||||||
|
wip_links( wip_html)
|
||||||
wip_quotes( wip_html.rsplit('\n'))
|
wip_quotes( wip_html.rsplit('\n'))
|
||||||
|
|
||||||
print('> Article HTML:')
|
print('> Article HTML:')
|
||||||
|
@ -114,7 +121,7 @@ def wip_begin_markers(wip_lines):
|
||||||
# Set marker (regex to find), HTML, Need CSS
|
# Set marker (regex to find), HTML, Need CSS
|
||||||
marks_html = [
|
marks_html = [
|
||||||
['^\|$|^\|\s' , '<br class="%s">' , True ],
|
['^\|$|^\|\s' , '<br class="%s">' , True ],
|
||||||
['^>>\s' , '<a class="%s"></a>' , True ],
|
['^>>\s' , '<a id="%s"></a>' , True ],
|
||||||
[r'^\($|\(\s' , '<p class="%s">' , True ],
|
[r'^\($|\(\s' , '<p class="%s">' , True ],
|
||||||
['^\)$|^\)\s' , '</p>' , False],
|
['^\)$|^\)\s' , '</p>' , False],
|
||||||
['^\[\[$|^\[\[\s' , '<precode class="%s"' , True ],
|
['^\[\[$|^\[\[\s' , '<precode class="%s"' , True ],
|
||||||
|
@ -187,6 +194,46 @@ def wip_titles(wip_lines):
|
||||||
|
|
||||||
wip_html = wip_tmp
|
wip_html = wip_tmp
|
||||||
|
|
||||||
|
|
||||||
|
#================================================#
|
||||||
|
# Create Anchors (links) #
|
||||||
|
# Target anchors are done with wip_begin_markers #
|
||||||
|
#------------------------------------------------#
|
||||||
|
def wip_anchors(article):
|
||||||
|
global wip_html
|
||||||
|
|
||||||
|
anchor_fmt = '<a class="anchor" href="%s">%s</a>'
|
||||||
|
anchors_link = re.findall(r'\>_(.*?)_\<', article)
|
||||||
|
|
||||||
|
for anchor in anchors_link:
|
||||||
|
anchor_id = anchor.rsplit(':',1)[0]
|
||||||
|
anchor_name = anchor.rsplit(':',1)[1]
|
||||||
|
article = article.replace('>_%s_<'%anchor,
|
||||||
|
anchor_fmt%(anchor_id, anchor_name)
|
||||||
|
)
|
||||||
|
wip_html = article
|
||||||
|
|
||||||
|
#
|
||||||
|
# Convert links
|
||||||
|
#
|
||||||
|
def wip_links(article):
|
||||||
|
global wip_html
|
||||||
|
|
||||||
|
link_fmt = '<a class="%s" href="%s" title="%s">%s</a>'
|
||||||
|
all_vars = set(globals())
|
||||||
|
|
||||||
|
for var in all_vars:
|
||||||
|
if var.startswith('link_'):
|
||||||
|
link = globals()[var]
|
||||||
|
article = article.replace('_%s'%link[0],
|
||||||
|
link_fmt%(
|
||||||
|
domain.domain_css, link[1],
|
||||||
|
link[2], link[0]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
wip_html = article
|
||||||
|
|
||||||
#======================================#
|
#======================================#
|
||||||
# Words Markers (strongs, emphasis...) #
|
# Words Markers (strongs, emphasis...) #
|
||||||
#--------------------------------------#
|
#--------------------------------------#
|
||||||
|
|
Loading…
Reference in New Issue