Удалено лишнее

This commit is contained in:
Andrei Astafev 2023-02-20 16:57:43 +03:00
parent ad070eb927
commit 440899bc41

View File

@ -6,7 +6,6 @@ import shutil
import subprocess
import bs4
from mwc.counter import count_words_in_markdown
from ruamel.yaml import YAML, constructor
from pelican import signals
@ -131,12 +130,6 @@ class PandocReader(BaseReader):
# Create table of contents and add to metadata
metadata["toc"] = self.process_metadata("toc", toc)
if self.settings.get("CALCULATE_READING_TIME", []):
# Calculate reading time and add to metadata
metadata["reading_time"] = self.process_metadata(
"reading_time", self._calculate_reading_time(content)
)
return output, metadata
def _validate_fields(self, defaults_files, arguments, extensions):
@ -206,24 +199,6 @@ class PandocReader(BaseReader):
return citations, table_of_contents
def _calculate_reading_time(self, content):
"""Calculate time taken to read content."""
reading_speed = self.settings.get("READING_SPEED", DEFAULT_READING_SPEED)
wordcount = count_words_in_markdown(content)
time_unit = "minutes"
try:
reading_time = math.ceil(float(wordcount) / float(reading_speed))
if reading_time == 1:
time_unit = "minute"
reading_time = "{} {}".format(str(reading_time), time_unit)
except ValueError as words_per_minute_nan:
raise ValueError(
"READING_SPEED setting must be a number."
) from words_per_minute_nan
return reading_time
def _process_metadata(self, pandoc_metadata):
"""Process Pandoc metadata and add it to Pelican."""
# Cycle through the metadata and process them